Skip to content

Commit a7f0a82

Browse files
authored
Drop 3.9 support for third-party packages (#15707)
Inline some unnecessary type aliases
1 parent c8c5e9e commit a7f0a82

12 files changed

Lines changed: 57 additions & 202 deletions

File tree

stubs/Markdown/markdown/util.pyi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
from collections.abc import Iterator
2+
from importlib import metadata
33
from re import Pattern
44
from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only
55

@@ -19,13 +19,7 @@ HTML_PLACEHOLDER_RE: Final[Pattern[str]]
1919
TAG_PLACEHOLDER: Final[str]
2020
RTL_BIDI_RANGES: Final[tuple[tuple[str, str], tuple[str, str]]]
2121

22-
if sys.version_info >= (3, 10):
23-
from importlib import metadata
24-
def get_installed_extensions() -> metadata.EntryPoints: ...
25-
26-
else:
27-
def get_installed_extensions(): ...
28-
22+
def get_installed_extensions() -> metadata.EntryPoints: ...
2923
def deprecated(message: str, stacklevel: int = 2): ...
3024
@overload
3125
def parseBoolValue(value: str) -> bool: ...

stubs/Pygments/pygments/plugin.pyi

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import sys
21
from _typeshed import Incomplete
32
from collections.abc import Generator
3+
from importlib.metadata import EntryPoints
44
from typing import Final
55

66
from pygments.filter import Filter
@@ -13,15 +13,7 @@ FORMATTER_ENTRY_POINT: Final = "pygments.formatters"
1313
STYLE_ENTRY_POINT: Final = "pygments.styles"
1414
FILTER_ENTRY_POINT: Final = "pygments.filters"
1515

16-
if sys.version_info >= (3, 10):
17-
from importlib.metadata import EntryPoints
18-
def iter_entry_points(group_name: str) -> EntryPoints: ...
19-
20-
else:
21-
from importlib.metadata import EntryPoint
22-
23-
def iter_entry_points(group_name: str) -> tuple[EntryPoint, ...] | list[EntryPoint]: ...
24-
16+
def iter_entry_points(group_name: str) -> EntryPoints: ...
2517
def find_plugin_lexers() -> Generator[type[Lexer]]: ...
2618
def find_plugin_formatters() -> Generator[tuple[str, type[Formatter[Incomplete]]]]: ...
2719
def find_plugin_styles() -> Generator[tuple[str, type[Style]]]: ...

stubs/click-web/click_web/resources/input_fields.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from typing import Any, ClassVar, Final
32

43
import click
@@ -47,10 +46,7 @@ class BaseInput:
4746
def _build_name(self, name: str) -> str: ...
4847

4948
class ChoiceInput(BaseInput):
50-
if sys.version_info >= (3, 10):
51-
param_type_cls: type[click.Choice[Any]]
52-
else:
53-
param_type_cls: type[click.Choice]
49+
param_type_cls: type[click.Choice[Any]]
5450

5551
class FlagInput(BaseInput):
5652
param_type_cls: None

stubs/fpdf2/fpdf/drawing.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import decimal
2-
import sys
32
from _typeshed import Incomplete, SupportsWrite
43
from collections import OrderedDict
54
from collections.abc import Callable, Generator, Iterable, Sequence
65
from contextlib import contextmanager
76
from re import Pattern
7+
from types import EllipsisType
88
from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only
99
from typing_extensions import Self
1010

11-
if sys.version_info >= (3, 10):
12-
from types import EllipsisType
13-
else:
14-
# Rely on builtins.ellipsis
15-
from builtins import ellipsis as EllipsisType
16-
1711
from .enums import PathPaintRule
1812
from .syntax import Name, Raw
1913

stubs/mock/mock/backports.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
import sys
1+
from inspect import iscoroutinefunction as iscoroutinefunction
22
from unittest import IsolatedAsyncioTestCase as IsolatedAsyncioTestCase
3-
4-
if sys.version_info >= (3, 10):
5-
from inspect import iscoroutinefunction as iscoroutinefunction
6-
else:
7-
from asyncio import iscoroutinefunction as iscoroutinefunction
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Stub-only module, can't be imported at runtime.
22

3-
import sys
43
from collections.abc import Collection
54
from typing import Any, Protocol, TypeAlias, type_check_only
65
from typing_extensions import TypeVar
@@ -13,17 +12,11 @@ _GenericT_co = TypeVar("_GenericT_co", bound=np.generic, covariant=True)
1312
_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True)
1413

1514
# numpy aliases
16-
if sys.version_info >= (3, 10):
17-
@type_check_only
18-
class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]):
19-
def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ...
20-
21-
ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]]
22-
else:
23-
# networkx does not support Python 3.9 but pyright still runs on 3.9 in CI
24-
# See https://github.com/python/typeshed/issues/10722
25-
ArrayLike1D: TypeAlias = Collection[_ScalarT] | np.ndarray[tuple[int], np.dtype[_GenericT]]
15+
@type_check_only
16+
class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]):
17+
def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ...
2618

19+
ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]]
2720
Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_GenericT]]
2821
Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_GenericT]]
2922
Seed: TypeAlias = int | np.random.Generator | np.random.RandomState

stubs/networkx/networkx/utils/configs.pyi

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from _typeshed import Incomplete
32
from collections.abc import Callable, ItemsView, Iterable, Iterator, KeysView, ValuesView
43
from dataclasses import dataclass
@@ -7,59 +6,30 @@ from typing_extensions import Self
76

87
__all__ = ["Config"]
98

10-
# TODO: Our pyright test doesn't understand `requires-python` in METADATA.toml
11-
# https://github.com/python/typeshed/issues/14025
12-
if sys.version_info >= (3, 10):
13-
@dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False)
14-
class Config:
15-
def __init_subclass__(cls, strict: bool = True) -> None: ...
16-
def __new__(cls, **kwargs) -> Self: ...
17-
def __dir__(self) -> Iterable[str]: ...
18-
def __setattr__(self, name: str, value) -> None: ...
19-
def __delattr__(self, name: str) -> None: ...
20-
def __contains__(self, key: object) -> bool: ...
21-
def __iter__(self) -> Iterator[str]: ...
22-
def __len__(self) -> int: ...
23-
def __reversed__(self) -> Iterator[str]: ...
24-
def __getitem__(self, key: str): ...
25-
def __setitem__(self, key: str, value) -> None: ...
26-
def __delitem__(self, key: str) -> None: ...
27-
def get(self, key: str, default=None): ...
28-
def items(self) -> ItemsView[str, Incomplete]: ...
29-
def keys(self) -> KeysView[str]: ...
30-
def values(self) -> ValuesView[Incomplete]: ...
31-
def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ...
32-
def __call__(self, **kwargs) -> Self: ...
33-
def __enter__(self) -> Self: ...
34-
def __exit__(
35-
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
36-
) -> None: ...
37-
38-
else:
39-
@dataclass(init=False, eq=False)
40-
class Config:
41-
def __init_subclass__(cls, strict: bool = True) -> None: ...
42-
def __new__(cls, **kwargs) -> Self: ...
43-
def __dir__(self) -> Iterable[str]: ...
44-
def __setattr__(self, name: str, value) -> None: ...
45-
def __delattr__(self, name: str) -> None: ...
46-
def __contains__(self, key: object) -> bool: ...
47-
def __iter__(self) -> Iterator[str]: ...
48-
def __len__(self) -> int: ...
49-
def __reversed__(self) -> Iterator[str]: ...
50-
def __getitem__(self, key: str): ...
51-
def __setitem__(self, key: str, value) -> None: ...
52-
def __delitem__(self, key: str) -> None: ...
53-
def get(self, key: str, default=None): ...
54-
def items(self) -> ItemsView[str, Incomplete]: ...
55-
def keys(self) -> KeysView[str]: ...
56-
def values(self) -> ValuesView[Incomplete]: ...
57-
def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ...
58-
def __call__(self, **kwargs) -> Self: ...
59-
def __enter__(self) -> Self: ...
60-
def __exit__(
61-
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
62-
) -> None: ...
9+
@dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False)
10+
class Config:
11+
def __init_subclass__(cls, strict: bool = True) -> None: ...
12+
def __new__(cls, **kwargs) -> Self: ...
13+
def __dir__(self) -> Iterable[str]: ...
14+
def __setattr__(self, name: str, value) -> None: ...
15+
def __delattr__(self, name: str) -> None: ...
16+
def __contains__(self, key: object) -> bool: ...
17+
def __iter__(self) -> Iterator[str]: ...
18+
def __len__(self) -> int: ...
19+
def __reversed__(self) -> Iterator[str]: ...
20+
def __getitem__(self, key: str): ...
21+
def __setitem__(self, key: str, value) -> None: ...
22+
def __delitem__(self, key: str) -> None: ...
23+
def get(self, key: str, default=None): ...
24+
def items(self) -> ItemsView[str, Incomplete]: ...
25+
def keys(self) -> KeysView[str]: ...
26+
def values(self) -> ValuesView[Incomplete]: ...
27+
def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ...
28+
def __call__(self, **kwargs) -> Self: ...
29+
def __enter__(self) -> Self: ...
30+
def __exit__(
31+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
32+
) -> None: ...
6333

6434
class NetworkXConfig(Config):
6535
backend_priority: list[str]

stubs/networkx/networkx/utils/misc.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import random
2-
import sys
32
from types import ModuleType
43
from typing import TypeAlias
5-
from typing_extensions import Self
64

75
import numpy
86
from networkx.classes.graph import Graph, _Node
@@ -39,10 +37,6 @@ def create_random_state(random_state=None): ...
3937

4038
class PythonRandomViaNumpyBits(random.Random):
4139
def __init__(self, rng: numpy.random.Generator | None = None) -> None: ...
42-
if sys.version_info < (3, 10):
43-
# this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624
44-
def __new__(cls, rng: numpy.random.Generator | None = None) -> Self: ...
45-
4640
def getrandbits(self, k: int) -> int: ...
4741

4842
class PythonRandomInterface:

stubs/pony/pony/orm/sqlbuilding.pyi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import types
32
from _typeshed import Incomplete
43
from collections.abc import Iterable
@@ -143,13 +142,8 @@ class SQLBuilder:
143142
def RANDOM(builder): ...
144143
def RAWSQL(builder, sql): ...
145144
def build_json_path(builder, path): ...
146-
if sys.version_info >= (3, 10):
147-
@classmethod
148-
def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ...
149-
else:
150-
@classmethod
151-
def eval_json_path(cls, values: Iterable[int | str | type | slice]) -> str: ...
152-
145+
@classmethod
146+
def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ...
153147
def JSON_QUERY(builder, expr, path) -> None: ...
154148
def JSON_VALUE(builder, expr, path, type) -> None: ...
155149
def JSON_NONZERO(builder, expr) -> None: ...

stubs/psutil/psutil/__init__.pyi

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -237,36 +237,6 @@ class Popen(Process):
237237
pipesize: int = -1,
238238
process_group: int | None = None,
239239
) -> None: ...
240-
elif sys.version_info >= (3, 10):
241-
def __init__(
242-
self,
243-
args: _CMD,
244-
bufsize: int = -1,
245-
executable: StrOrBytesPath | None = None,
246-
stdin: _FILE | None = None,
247-
stdout: _FILE | None = None,
248-
stderr: _FILE | None = None,
249-
preexec_fn: Callable[[], object] | None = None,
250-
close_fds: bool = True,
251-
shell: bool = False,
252-
cwd: StrOrBytesPath | None = None,
253-
env: _ENV | None = None,
254-
universal_newlines: bool | None = None,
255-
startupinfo: Any | None = None,
256-
creationflags: int = 0,
257-
restore_signals: bool = True,
258-
start_new_session: bool = False,
259-
pass_fds: Collection[int] = (),
260-
*,
261-
text: bool | None = None,
262-
encoding: str | None = None,
263-
errors: str | None = None,
264-
user: str | int | None = None,
265-
group: str | int | None = None,
266-
extra_groups: Iterable[str | int] | None = None,
267-
umask: int = -1,
268-
pipesize: int = -1,
269-
) -> None: ...
270240
else:
271241
def __init__(
272242
self,
@@ -295,6 +265,7 @@ class Popen(Process):
295265
group: str | int | None = None,
296266
extra_groups: Iterable[str | int] | None = None,
297267
umask: int = -1,
268+
pipesize: int = -1,
298269
) -> None: ...
299270

300271
def __enter__(self) -> Self: ...

0 commit comments

Comments
 (0)