Drop support for Python 3.12 (#14762)

This commit is contained in:
Adam Turner authored and GitHub committed 2026-10-20 14:11:44 -07:00
1 parent 943bf0d191
commit 9448f26ec6
34 files changed
+136 -225

No files matched your search

+1 -1
View File
@@ -283,7 +283,7 @@ def test_pending_warnings(app: SphinxTestApp) -> None:
@contextmanager
def force_colors() -> Generator[None, None, None]:
def force_colors() -> Generator[None]:
forcecolor = os.environ.get('FORCE_COLOR', None)
try:
+35 -11
View File
@@ -141,7 +141,7 @@ def test_is_invalid_builtin_class() -> None:
# if these tests start failing, it means that the __module__
# of one of these classes has changed, and _INVALID_BUILTIN_CLASSES
# in sphinx.util.typing needs to be updated.
invalid_types = (
invalid_types: tuple[type, ...] = (
# contextvars
Context,
ContextVar,
@@ -202,7 +202,7 @@ def test_is_invalid_builtin_class() -> None:
zipfile.Path,
zipfile.CompleteDirs,
)
if sys.version_info[:2] == (3, 13):
if sys.version_info[:2] < (3, 14):
invalid_types += (
# pathlib
Path,
@@ -214,7 +214,7 @@ def test_is_invalid_builtin_class() -> None:
)
invalid_names = {(cls.__module__, cls.__qualname__) for cls in invalid_types}
if sys.version_info[:2] != (3, 13):
if sys.version_info[:2] >= (3, 14):
invalid_names |= {
('pathlib._local', 'Path'),
('pathlib._local', 'PosixPath'),
@@ -254,16 +254,24 @@ def test_restify_type_hints_containers():
'[:py:class:`~typing.Tuple`\\ '
'[:py:class:`int`, :py:class:`int`]]'
)
assert restify(t.Generator[None, None, None]) == (
assert restify(t.Generator[None, None, None]) == ( # ruff: ignore[unnecessary-default-type-args]
':py:class:`~typing.Generator`\\ '
'[:py:obj:`None`, :py:obj:`None`, '
':py:obj:`None`]'
)
assert restify(abc.Generator[None, None, None]) == (
assert restify(t.Generator[None]) == (
':py:class:`~typing.Generator`\\ '
'[:py:obj:`None`, :py:obj:`None`, '
':py:obj:`None`]'
)
assert restify(abc.Generator[None, None, None]) == ( # ruff: ignore[unnecessary-default-type-args]
':py:class:`collections.abc.Generator`\\ '
'[:py:obj:`None`, :py:obj:`None`, '
':py:obj:`None`]'
)
assert restify(abc.Generator[None]) == (
':py:class:`collections.abc.Generator`\\ [:py:obj:`None`]'
)
assert restify(t.Iterator[None]) == (
':py:class:`~typing.Iterator`\\ [:py:obj:`None`]'
)
@@ -625,23 +633,39 @@ def test_stringify_type_hints_containers():
)
ann_str = stringify_annotation(
t.Generator[None, None, None], 'fully-qualified-except-typing'
t.Generator[None, None, None], # ruff: ignore[unnecessary-default-type-args]
'fully-qualified-except-typing',
)
assert ann_str == 'Generator[None, None, None]'
ann_str = stringify_annotation(t.Generator[None, None, None], 'fully-qualified')
ann_str = stringify_annotation(t.Generator[None, None, None], 'fully-qualified') # ruff: ignore[unnecessary-default-type-args]
assert ann_str == 'typing.Generator[None, None, None]'
ann_str = stringify_annotation(t.Generator[None, None, None], 'smart')
ann_str = stringify_annotation(t.Generator[None, None, None], 'smart') # ruff: ignore[unnecessary-default-type-args]
assert ann_str == '~typing.Generator[None, None, None]'
ann_str = stringify_annotation(t.Generator[None], 'fully-qualified-except-typing')
assert ann_str == 'Generator[None, None, None]'
ann_str = stringify_annotation(t.Generator[None], 'fully-qualified')
assert ann_str == 'typing.Generator[None, None, None]'
ann_str = stringify_annotation(t.Generator[None], 'smart')
assert ann_str == '~typing.Generator[None, None, None]'
ann_str = stringify_annotation(
abc.Generator[None, None, None], 'fully-qualified-except-typing'
abc.Generator[None, None, None], # ruff: ignore[unnecessary-default-type-args]
'fully-qualified-except-typing',
)
assert ann_str == 'collections.abc.Generator[None, None, None]'
ann_str = stringify_annotation(abc.Generator[None, None, None], 'fully-qualified')
ann_str = stringify_annotation(abc.Generator[None, None, None], 'fully-qualified') # ruff: ignore[unnecessary-default-type-args]
assert ann_str == 'collections.abc.Generator[None, None, None]'
ann_str = stringify_annotation(abc.Generator[None, None, None], 'smart')
ann_str = stringify_annotation(abc.Generator[None, None, None], 'smart') # ruff: ignore[unnecessary-default-type-args]
assert ann_str == '~collections.abc.Generator[None, None, None]'
ann_str = stringify_annotation(abc.Generator[None], 'fully-qualified-except-typing')
assert ann_str == 'collections.abc.Generator[None]'
ann_str = stringify_annotation(abc.Generator[None], 'fully-qualified')
assert ann_str == 'collections.abc.Generator[None]'
ann_str = stringify_annotation(abc.Generator[None], 'smart')
assert ann_str == '~collections.abc.Generator[None]'
ann_str = stringify_annotation(t.Iterator[None], 'fully-qualified-except-typing')
assert ann_str == 'Iterator[None]'
ann_str = stringify_annotation(t.Iterator[None], 'fully-qualified')