Skip to content

Commit 3af4852

Browse files
committed
Require the PEP 563 'annotations' future import
1 parent 0e15ad7 commit 3af4852

File tree

122 files changed

+294
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+294
-17
lines changed

.ruff.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ select = [
295295
"TC001", # documentation doesn't need type-checking blocks
296296
]
297297
"doc/conf.py" = ["INP001", "W605"]
298-
"doc/development/tutorials/examples/*" = ["INP001"]
298+
"doc/development/tutorials/examples/*" = ["I002", "INP001"]
299299
# allow print() in the tutorial
300300
"doc/development/tutorials/examples/recipe.py" = [
301301
"FURB118",
@@ -360,7 +360,7 @@ select = [
360360

361361
# these tests need old ``typing`` generic aliases
362362
"tests/test_util/test_util_typing.py" = ["UP006", "UP007", "UP035"]
363-
"tests/test_util/typing_test_data.py" = ["FA100", "PYI030", "UP006", "UP007", "UP035"]
363+
"tests/test_util/typing_test_data.py" = ["FA100", "I002", "PYI030", "UP006", "UP007", "UP035"]
364364

365365
"utils/*" = [
366366
"T201", # whitelist ``print`` for stdout messages
@@ -377,6 +377,9 @@ inline-quotes = "single"
377377
forced-separate = [
378378
"tests",
379379
]
380+
required-imports = [
381+
"from __future__ import annotations",
382+
]
380383

381384
[format]
382385
preview = true

sphinx/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""The Sphinx documentation toolchain."""
22

3+
from __future__ import annotations
4+
35
__version__ = '8.2.0'
46
__display_version__ = __version__ # used for command line version
57

sphinx/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""The Sphinx documentation toolchain."""
22

3+
from __future__ import annotations
4+
35
import sys
46

57
from sphinx.cmd.build import main

sphinx/builders/latex/nodes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Additional nodes for LaTeX writer."""
22

3+
from __future__ import annotations
4+
35
from docutils import nodes
46

57

sphinx/environment/adapters/asset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
"""Assets adapter for sphinx.environment."""
22

3-
from sphinx.environment import BuildEnvironment
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
47
from sphinx.util._pathlib import _StrPath
58

9+
if TYPE_CHECKING:
10+
from sphinx.environment import BuildEnvironment
11+
612

713
class ImageAdapter:
814
def __init__(self, env: BuildEnvironment) -> None:

sphinx/ext/intersphinx/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Command line interface for the intersphinx extension."""
22

3+
from __future__ import annotations
4+
35
import logging as _logging
46
import sys
57

sphinx/pygments_styles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Sphinx theme specific highlighting styles."""
22

3+
from __future__ import annotations
4+
35
from pygments.style import Style
46
from pygments.styles.friendly import FriendlyStyle
57
from pygments.token import (

sphinx/testing/restructuredtext.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
from docutils import nodes
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
25
from docutils.core import publish_doctree
36

4-
from sphinx.application import Sphinx
57
from sphinx.io import SphinxStandaloneReader
68
from sphinx.parsers import RSTParser
79
from sphinx.util.docutils import sphinx_domains
810

11+
if TYPE_CHECKING:
12+
from docutils import nodes
13+
14+
from sphinx.application import Sphinx
15+
916

1017
def parse(app: Sphinx, text: str, docname: str = 'index') -> nodes.document:
1118
"""Parse a string as reStructuredText with Sphinx application."""

sphinx/util/_lines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
def parse_line_num_spec(spec: str, total: int) -> list[int]:
25
"""Parse a line number spec (such as "1,2,4-6") and return a list of
36
wanted line numbers.

sphinx/util/build_phase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Build phase of Sphinx application."""
22

3+
from __future__ import annotations
4+
35
from enum import IntEnum
46

57

0 commit comments

Comments
 (0)