diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index f30f9e08432c..b942839a95f4 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -1,5 +1,5 @@ -import sys from collections.abc import Iterator +from importlib import metadata from re import Pattern from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only @@ -19,13 +19,7 @@ HTML_PLACEHOLDER_RE: Final[Pattern[str]] TAG_PLACEHOLDER: Final[str] RTL_BIDI_RANGES: Final[tuple[tuple[str, str], tuple[str, str]]] -if sys.version_info >= (3, 10): - from importlib import metadata - def get_installed_extensions() -> metadata.EntryPoints: ... - -else: - def get_installed_extensions(): ... - +def get_installed_extensions() -> metadata.EntryPoints: ... def deprecated(message: str, stacklevel: int = 2): ... @overload def parseBoolValue(value: str) -> bool: ... diff --git a/stubs/Pygments/pygments/plugin.pyi b/stubs/Pygments/pygments/plugin.pyi index a11c89351400..49b49c9d7641 100644 --- a/stubs/Pygments/pygments/plugin.pyi +++ b/stubs/Pygments/pygments/plugin.pyi @@ -1,6 +1,6 @@ -import sys from _typeshed import Incomplete from collections.abc import Generator +from importlib.metadata import EntryPoints from typing import Final from pygments.filter import Filter @@ -13,15 +13,7 @@ FORMATTER_ENTRY_POINT: Final = "pygments.formatters" STYLE_ENTRY_POINT: Final = "pygments.styles" FILTER_ENTRY_POINT: Final = "pygments.filters" -if sys.version_info >= (3, 10): - from importlib.metadata import EntryPoints - def iter_entry_points(group_name: str) -> EntryPoints: ... - -else: - from importlib.metadata import EntryPoint - - def iter_entry_points(group_name: str) -> tuple[EntryPoint, ...] | list[EntryPoint]: ... - +def iter_entry_points(group_name: str) -> EntryPoints: ... def find_plugin_lexers() -> Generator[type[Lexer]]: ... def find_plugin_formatters() -> Generator[tuple[str, type[Formatter[Incomplete]]]]: ... def find_plugin_styles() -> Generator[tuple[str, type[Style]]]: ... diff --git a/stubs/click-web/click_web/resources/input_fields.pyi b/stubs/click-web/click_web/resources/input_fields.pyi index ec2ede4d14b2..a77853d9f5df 100644 --- a/stubs/click-web/click_web/resources/input_fields.pyi +++ b/stubs/click-web/click_web/resources/input_fields.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, ClassVar, Final import click @@ -47,10 +46,7 @@ class BaseInput: def _build_name(self, name: str) -> str: ... class ChoiceInput(BaseInput): - if sys.version_info >= (3, 10): - param_type_cls: type[click.Choice[Any]] - else: - param_type_cls: type[click.Choice] + param_type_cls: type[click.Choice[Any]] class FlagInput(BaseInput): param_type_cls: None diff --git a/stubs/fpdf2/fpdf/drawing.pyi b/stubs/fpdf2/fpdf/drawing.pyi index 65bdd2cec40d..2bcb2a1456c5 100644 --- a/stubs/fpdf2/fpdf/drawing.pyi +++ b/stubs/fpdf2/fpdf/drawing.pyi @@ -1,19 +1,13 @@ import decimal -import sys from _typeshed import Incomplete, SupportsWrite from collections import OrderedDict from collections.abc import Callable, Generator, Iterable, Sequence from contextlib import contextmanager from re import Pattern +from types import EllipsisType from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only from typing_extensions import Self -if sys.version_info >= (3, 10): - from types import EllipsisType -else: - # Rely on builtins.ellipsis - from builtins import ellipsis as EllipsisType - from .enums import PathPaintRule from .syntax import Name, Raw diff --git a/stubs/mock/mock/backports.pyi b/stubs/mock/mock/backports.pyi index fd968db5d6cb..9cb45af2cd60 100644 --- a/stubs/mock/mock/backports.pyi +++ b/stubs/mock/mock/backports.pyi @@ -1,7 +1,2 @@ -import sys +from inspect import iscoroutinefunction as iscoroutinefunction from unittest import IsolatedAsyncioTestCase as IsolatedAsyncioTestCase - -if sys.version_info >= (3, 10): - from inspect import iscoroutinefunction as iscoroutinefunction -else: - from asyncio import iscoroutinefunction as iscoroutinefunction diff --git a/stubs/networkx/networkx/_typing.pyi b/stubs/networkx/networkx/_typing.pyi index 438fdebe93b1..b82d9673deb0 100644 --- a/stubs/networkx/networkx/_typing.pyi +++ b/stubs/networkx/networkx/_typing.pyi @@ -1,6 +1,5 @@ # Stub-only module, can't be imported at runtime. -import sys from collections.abc import Collection from typing import Any, Protocol, TypeAlias, type_check_only from typing_extensions import TypeVar @@ -13,17 +12,11 @@ _GenericT_co = TypeVar("_GenericT_co", bound=np.generic, covariant=True) _ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True) # numpy aliases -if sys.version_info >= (3, 10): - @type_check_only - class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): - def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... - - ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] -else: - # networkx does not support Python 3.9 but pyright still runs on 3.9 in CI - # See https://github.com/python/typeshed/issues/10722 - ArrayLike1D: TypeAlias = Collection[_ScalarT] | np.ndarray[tuple[int], np.dtype[_GenericT]] +@type_check_only +class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): + def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... +ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_GenericT]] Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_GenericT]] Seed: TypeAlias = int | np.random.Generator | np.random.RandomState diff --git a/stubs/networkx/networkx/utils/configs.pyi b/stubs/networkx/networkx/utils/configs.pyi index b9206c9ace09..46d843940841 100644 --- a/stubs/networkx/networkx/utils/configs.pyi +++ b/stubs/networkx/networkx/utils/configs.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete from collections.abc import Callable, ItemsView, Iterable, Iterator, KeysView, ValuesView from dataclasses import dataclass @@ -7,59 +6,30 @@ from typing_extensions import Self __all__ = ["Config"] -# TODO: Our pyright test doesn't understand `requires-python` in METADATA.toml -# https://github.com/python/typeshed/issues/14025 -if sys.version_info >= (3, 10): - @dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) - class Config: - def __init_subclass__(cls, strict: bool = True) -> None: ... - def __new__(cls, **kwargs) -> Self: ... - def __dir__(self) -> Iterable[str]: ... - def __setattr__(self, name: str, value) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[str]: ... - def __getitem__(self, key: str): ... - def __setitem__(self, key: str, value) -> None: ... - def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default=None): ... - def items(self) -> ItemsView[str, Incomplete]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[Incomplete]: ... - def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... - def __call__(self, **kwargs) -> Self: ... - def __enter__(self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None - ) -> None: ... - -else: - @dataclass(init=False, eq=False) - class Config: - def __init_subclass__(cls, strict: bool = True) -> None: ... - def __new__(cls, **kwargs) -> Self: ... - def __dir__(self) -> Iterable[str]: ... - def __setattr__(self, name: str, value) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[str]: ... - def __getitem__(self, key: str): ... - def __setitem__(self, key: str, value) -> None: ... - def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default=None): ... - def items(self) -> ItemsView[str, Incomplete]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[Incomplete]: ... - def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... - def __call__(self, **kwargs) -> Self: ... - def __enter__(self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None - ) -> None: ... +@dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) +class Config: + def __init_subclass__(cls, strict: bool = True) -> None: ... + def __new__(cls, **kwargs) -> Self: ... + def __dir__(self) -> Iterable[str]: ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def __reversed__(self) -> Iterator[str]: ... + def __getitem__(self, key: str): ... + def __setitem__(self, key: str, value) -> None: ... + def __delitem__(self, key: str) -> None: ... + def get(self, key: str, default=None): ... + def items(self) -> ItemsView[str, Incomplete]: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[Incomplete]: ... + def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... + def __call__(self, **kwargs) -> Self: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> None: ... class NetworkXConfig(Config): backend_priority: list[str] diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index 566c5c83d795..b87ff7572956 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -1,8 +1,6 @@ import random -import sys from types import ModuleType from typing import TypeAlias -from typing_extensions import Self import numpy from networkx.classes.graph import Graph, _Node @@ -39,10 +37,6 @@ def create_random_state(random_state=None): ... class PythonRandomViaNumpyBits(random.Random): def __init__(self, rng: numpy.random.Generator | None = None) -> None: ... - if sys.version_info < (3, 10): - # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 - def __new__(cls, rng: numpy.random.Generator | None = None) -> Self: ... - def getrandbits(self, k: int) -> int: ... class PythonRandomInterface: diff --git a/stubs/pony/pony/orm/sqlbuilding.pyi b/stubs/pony/pony/orm/sqlbuilding.pyi index abfe2f849511..e123d2be9993 100644 --- a/stubs/pony/pony/orm/sqlbuilding.pyi +++ b/stubs/pony/pony/orm/sqlbuilding.pyi @@ -1,4 +1,3 @@ -import sys import types from _typeshed import Incomplete from collections.abc import Iterable @@ -143,13 +142,8 @@ class SQLBuilder: def RANDOM(builder): ... def RAWSQL(builder, sql): ... def build_json_path(builder, path): ... - if sys.version_info >= (3, 10): - @classmethod - def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... - else: - @classmethod - def eval_json_path(cls, values: Iterable[int | str | type | slice]) -> str: ... - + @classmethod + def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... def JSON_QUERY(builder, expr, path) -> None: ... def JSON_VALUE(builder, expr, path, type) -> None: ... def JSON_NONZERO(builder, expr) -> None: ... diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 4f323673c7f5..c54581f8d668 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -237,36 +237,6 @@ class Popen(Process): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> None: ... else: def __init__( self, @@ -295,6 +265,7 @@ class Popen(Process): group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> None: ... def __enter__(self) -> Self: ... diff --git a/stubs/pyflakes/pyflakes/checker.pyi b/stubs/pyflakes/pyflakes/checker.pyi index e8f1874caba9..bb3f8c09e658 100644 --- a/stubs/pyflakes/pyflakes/checker.pyi +++ b/stubs/pyflakes/pyflakes/checker.pyi @@ -9,8 +9,7 @@ from typing_extensions import Never from pyflakes.messages import Message -_AnyFunction: TypeAlias = Callable[..., Any] -_F = TypeVar("_F", bound=_AnyFunction) +_F = TypeVar("_F", bound=Callable[..., Any]) _P = ParamSpec("_P") PYPY: Final[bool] @@ -19,12 +18,7 @@ builtin_vars: Final[list[str]] def parse_format_string( format_string: StrOrLiteralStr, ) -> Iterable[tuple[StrOrLiteralStr, StrOrLiteralStr | None, StrOrLiteralStr | None, StrOrLiteralStr | None]]: ... - -if sys.version_info >= (3, 10): - def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... - -else: - def getAlternatives(n: ast.If | ast.Try) -> list[ast.AST]: ... +def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... FOR_TYPES: Final[tuple[type[ast.For], type[ast.AsyncFor]]] MAPPING_KEY_RE: Final[Pattern[str]] @@ -149,30 +143,6 @@ class AnnotationState: def in_annotation(func: _F) -> _F: ... def in_string_annotation(func: _F) -> _F: ... -if sys.version_info >= (3, 10): - _Match: TypeAlias = ast.Match - _MatchCase: TypeAlias = ast.match_case - _MatchValue: TypeAlias = ast.MatchValue - _MatchSingleton: TypeAlias = ast.MatchSingleton - _MatchSequence: TypeAlias = ast.MatchSequence - _MatchStar: TypeAlias = ast.MatchStar - _MatchMapping: TypeAlias = ast.MatchMapping - _MatchClass: TypeAlias = ast.MatchClass - _MatchAs: TypeAlias = ast.MatchAs - _MatchOr: TypeAlias = ast.MatchOr -else: - # The methods using these should never be called on Python < 3.10. - _Match: TypeAlias = Never - _MatchCase: TypeAlias = Never - _MatchValue: TypeAlias = Never - _MatchSingleton: TypeAlias = Never - _MatchSequence: TypeAlias = Never - _MatchStar: TypeAlias = Never - _MatchMapping: TypeAlias = Never - _MatchClass: TypeAlias = Never - _MatchAs: TypeAlias = Never - _MatchOr: TypeAlias = Never - if sys.version_info >= (3, 12): _TypeVar: TypeAlias = ast.TypeVar _ParamSpec: TypeAlias = ast.ParamSpec @@ -214,7 +184,7 @@ class Checker: withDoctest: bool = False, file_tokens: Unused = (), ) -> None: ... - def deferFunction(self, callable: _AnyFunction) -> None: ... + def deferFunction(self, callable: Callable[..., Any]) -> None: ... @property def futuresAllowed(self) -> bool: ... @futuresAllowed.setter @@ -352,16 +322,16 @@ class Checker: def EXCEPTHANDLER(self, node: ast.ExceptHandler) -> None: ... def ANNASSIGN(self, node: ast.AnnAssign) -> None: ... def COMPARE(self, node: ast.Compare) -> None: ... - def MATCH(self, tree: _Match, omit: _OmitType = None) -> None: ... - def MATCH_CASE(self, tree: _MatchCase, omit: _OmitType = None) -> None: ... - def MATCHCLASS(self, tree: _MatchClass, omit: _OmitType = None) -> None: ... - def MATCHOR(self, tree: _MatchOr, omit: _OmitType = None) -> None: ... - def MATCHSEQUENCE(self, tree: _MatchSequence, omit: _OmitType = None) -> None: ... - def MATCHSINGLETON(self, tree: _MatchSingleton, omit: _OmitType = None) -> None: ... - def MATCHVALUE(self, tree: _MatchValue, omit: _OmitType = None) -> None: ... - def MATCHAS(self, node: _MatchAs) -> None: ... - def MATCHMAPPING(self, node: _MatchMapping) -> None: ... - def MATCHSTAR(self, node: _MatchStar) -> None: ... + def MATCH(self, tree: ast.Match, omit: _OmitType = None) -> None: ... + def MATCH_CASE(self, tree: ast.match_case, omit: _OmitType = None) -> None: ... + def MATCHCLASS(self, tree: ast.MatchClass, omit: _OmitType = None) -> None: ... + def MATCHOR(self, tree: ast.MatchOr, omit: _OmitType = None) -> None: ... + def MATCHSEQUENCE(self, tree: ast.MatchSequence, omit: _OmitType = None) -> None: ... + def MATCHSINGLETON(self, tree: ast.MatchSingleton, omit: _OmitType = None) -> None: ... + def MATCHVALUE(self, tree: ast.MatchValue, omit: _OmitType = None) -> None: ... + def MATCHAS(self, node: ast.MatchAs) -> None: ... + def MATCHMAPPING(self, node: ast.MatchMapping) -> None: ... + def MATCHSTAR(self, node: ast.MatchStar) -> None: ... def TYPEVAR(self, node: _TypeVar) -> None: ... def PARAMSPEC(self, node: _ParamSpec) -> None: ... def TYPEVARTUPLE(self, node: _TypeVarTuple) -> None: ... diff --git a/stubs/shapely/shapely/predicates.pyi b/stubs/shapely/shapely/predicates.pyi index cf8bd68b7772..2145c60b54a9 100644 --- a/stubs/shapely/shapely/predicates.pyi +++ b/stubs/shapely/shapely/predicates.pyi @@ -1,5 +1,4 @@ -import sys -from typing import Any, Literal, TypeAlias, TypeGuard, overload +from typing import Any, Literal, TypeGuard, overload import numpy as np from numpy.typing import NDArray @@ -8,13 +7,6 @@ from ._typing import ArrayLike, ArrayLikeSeq, OptGeoArrayLike, OptGeoArrayLikeSe from .geometry.base import BaseGeometry from .lib import Geometry -if sys.version_info >= (3, 10): - _NPTrue: TypeAlias = np.bool_[Literal[True]] - _NPFalse: TypeAlias = np.bool_[Literal[False]] -else: - _NPTrue: TypeAlias = np.bool_ - _NPFalse: TypeAlias = np.bool_ - __all__ = [ "contains", "contains_properly", @@ -70,17 +62,17 @@ def is_empty(geometry: Geometry | None, **kwargs) -> np.bool_: ... @overload def is_empty(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ... @overload -def is_geometry(geometry: Geometry, **kwargs) -> _NPTrue: ... +def is_geometry(geometry: Geometry, **kwargs) -> np.bool_[Literal[True]]: ... @overload -def is_geometry(geometry: None, **kwargs) -> _NPFalse: ... +def is_geometry(geometry: None, **kwargs) -> np.bool_[Literal[False]]: ... @overload def is_geometry(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] @overload def is_geometry(geometry: object, **kwargs) -> TypeGuard[BaseGeometry]: ... @overload -def is_missing(geometry: Geometry, **kwargs) -> _NPFalse: ... +def is_missing(geometry: Geometry, **kwargs) -> np.bool_[Literal[False]]: ... @overload -def is_missing(geometry: None, **kwargs) -> _NPTrue: ... +def is_missing(geometry: None, **kwargs) -> np.bool_[Literal[True]]: ... @overload def is_missing(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] @overload @@ -90,7 +82,7 @@ def is_prepared(geometry: Geometry | None, **kwargs) -> np.bool_: ... @overload def is_prepared(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ... @overload -def is_valid_input(geometry: Geometry | None, **kwargs) -> _NPTrue: ... +def is_valid_input(geometry: Geometry | None, **kwargs) -> np.bool_[Literal[True]]: ... @overload def is_valid_input(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] @overload