diff --git a/stdlib/lib2to3/pgen2/__init__.pyi b/stdlib/lib2to3/pgen2/__init__.pyi index e69de29bb..15c76865d 100644 --- a/stdlib/lib2to3/pgen2/__init__.pyi +++ b/stdlib/lib2to3/pgen2/__init__.pyi @@ -0,0 +1,8 @@ +from collections.abc import Callable +from lib2to3.pgen2.grammar import Grammar +from lib2to3.pytree import _RawNode +from typing import Any +from typing_extensions import TypeAlias + +# This is imported in several lib2to3/pgen2 submodules +_Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index 61ec90b4d..45c9aeaa5 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -1,7 +1,8 @@ from _typeshed import StrPath from collections.abc import Iterable +from lib2to3.pgen2 import _Convert from lib2to3.pgen2.grammar import Grammar -from lib2to3.pytree import _NL, _Convert +from lib2to3.pytree import _NL from logging import Logger from typing import IO, Any diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index 14d6004d3..6a07c4a4a 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,7 @@ from collections.abc import Sequence +from lib2to3.pgen2 import _Convert from lib2to3.pgen2.grammar import _DFAS, Grammar -from lib2to3.pytree import _NL, _Convert, _RawNode +from lib2to3.pytree import _NL, _RawNode from typing import Any from typing_extensions import TypeAlias diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 208a87da8..4db9ab99b 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,5 +1,5 @@ from _typeshed import Self -from collections.abc import Callable, Iterator +from collections.abc import Iterator from lib2to3.pgen2.grammar import Grammar from typing import Any from typing_extensions import TypeAlias @@ -8,9 +8,6 @@ _NL: TypeAlias = Node | Leaf _Context: TypeAlias = tuple[str, int, int] _Results: TypeAlias = dict[str, _NL] _RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None] -# This alias isn't used in this file, -# but is imported in other lib2to3 submodules -_Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] HUGE: int diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 44595d5ae..01c4c226e 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -14,7 +14,6 @@ _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None _AdaptedInputData: TypeAlias = _SqliteData | Any # The Mapping must really be a dict, but making it invariant is too annoying. _Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData] -_SqliteOutputData: TypeAlias = str | bytes | int | float | None _Adapter: TypeAlias = Callable[[_T], _SqliteData] _Converter: TypeAlias = Callable[[bytes], Any] diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 9b113e5ef..a1c875561 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -11,7 +11,7 @@ from typing_extensions import Literal, TypeAlias, final _T = TypeVar("_T") -_OptExcInfo: TypeAlias = OptExcInfo # TODO: obsolete, remove fall 2022 or later +_OptExcInfo: TypeAlias = OptExcInfo # noqa: Y047 # TODO: obsolete, remove fall 2022 or later # Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder` class _MetaPathFinder(Protocol): diff --git a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/infer.pyi b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/infer.pyi index 689bcc565..0ffb05b70 100644 --- a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/infer.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/infer.pyi @@ -7,7 +7,6 @@ _Expression: TypeAlias = Any # mypy.nodes.Expression _RefExpr: TypeAlias = Any # mypy.nodes.RefExpr _TypeInfo: TypeAlias = Any # mypy.nodes.TypeInfo _Var: TypeAlias = Any # mypy.nodes.Var -_StrExpr: TypeAlias = Any # mypy.nodes.StrExpr _SemanticAnalyzerPluginInterface: TypeAlias = Any # mypy.plugin.SemanticAnalyzerPluginInterface _ProperType: TypeAlias = Any # mypy.types.ProperType diff --git a/stubs/SQLAlchemy/sqlalchemy/orm/persistence.pyi b/stubs/SQLAlchemy/sqlalchemy/orm/persistence.pyi index 727e35802..8d5d721e7 100644 --- a/stubs/SQLAlchemy/sqlalchemy/orm/persistence.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/orm/persistence.pyi @@ -1,11 +1,8 @@ from typing import Any -from typing_extensions import Literal, TypeAlias from ..sql.base import CompileState, Options from ..sql.dml import DeleteDMLState, UpdateDMLState -_SynchronizeSessionArgument: TypeAlias = Literal[False, "evaluate", "fetch"] - def save_obj(base_mapper, states, uowtransaction, single: bool = ...) -> None: ... def post_update(base_mapper, states, uowtransaction, post_update_cols) -> None: ... def delete_obj(base_mapper, states, uowtransaction) -> None: ... diff --git a/stubs/SQLAlchemy/sqlalchemy/orm/query.pyi b/stubs/SQLAlchemy/sqlalchemy/orm/query.pyi index b7359927c..21aef16fd 100644 --- a/stubs/SQLAlchemy/sqlalchemy/orm/query.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/orm/query.pyi @@ -1,18 +1,19 @@ from _typeshed import Self from collections.abc import Iterator from typing import Any, Generic, TypeVar +from typing_extensions import Literal, TypeAlias from ..sql.annotation import SupportsCloneAnnotations from ..sql.base import Executable from ..sql.selectable import GroupedElement, HasHints, HasPrefixes, HasSuffixes, SelectBase, _SelectFromElements from . import interfaces from .context import QueryContext as QueryContext -from .persistence import _SynchronizeSessionArgument from .util import aliased as aliased __all__ = ["Query", "QueryContext", "aliased"] _T = TypeVar("_T") +_SynchronizeSessionArgument: TypeAlias = Literal[False, "evaluate", "fetch"] class Query(_SelectFromElements, SupportsCloneAnnotations, HasPrefixes, HasSuffixes, HasHints, Executable, Generic[_T]): logger: Any diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 868dc1b66..a7ea030c1 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -3,6 +3,7 @@ from _typeshed import Self from collections.abc import Callable, Iterable, Iterator from contextlib import AbstractContextManager from typing import Any +from typing_extensions import Literal, TypeAlias from ._common import ( AIX as AIX, @@ -50,7 +51,6 @@ from ._common import ( NoSuchProcess as NoSuchProcess, TimeoutExpired as TimeoutExpired, ZombieProcess as ZombieProcess, - _Status, pconn, pcputimes, pctxsw, @@ -118,6 +118,23 @@ version_info: tuple[int, int, int] __version__: str __author__: str +_Status: TypeAlias = Literal[ + "running", + "sleeping", + "disk-sleep", + "stopped", + "tracing-stop", + "zombie", + "dead", + "wake-kill", + "waking", + "idle", + "locked", + "waiting", + "suspended", + "parked", +] + class Process: def __init__(self, pid: int | None = ...) -> None: ... def __eq__(self, other: object) -> bool: ... diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index 9c854e732..aed998d38 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -3,7 +3,7 @@ from _typeshed import StrOrBytesPath, SupportsWrite from collections.abc import Callable from socket import AddressFamily, SocketKind from typing import Any, NamedTuple, TypeVar, overload -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal POSIX: bool WINDOWS: bool @@ -32,23 +32,6 @@ STATUS_WAITING: Literal["waiting"] STATUS_SUSPENDED: Literal["suspended"] STATUS_PARKED: Literal["parked"] -_Status: TypeAlias = Literal[ - "running", - "sleeping", - "disk-sleep", - "stopped", - "tracing-stop", - "zombie", - "dead", - "wake-kill", - "waking", - "idle", - "locked", - "waiting", - "suspended", - "parked", -] - CONN_ESTABLISHED: str CONN_SYN_SENT: str CONN_SYN_RECV: str diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index 0006f6851..c4b3d5c5f 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -1,19 +1,11 @@ +from collections.abc import Mapping from typing import Any +from typing_extensions import TypeAlias from .models import Response -from .sessions import ( - RequestsCookieJar, - _Auth, - _Cert, - _Data, - _Files, - _HeadersMapping, - _HooksInput, - _Params, - _TextMapping, - _Timeout, - _Verify, -) +from .sessions import RequestsCookieJar, _Auth, _Cert, _Data, _Files, _HooksInput, _Params, _TextMapping, _Timeout, _Verify + +_HeadersMapping: TypeAlias = Mapping[str, str | bytes] def request( method: str | bytes, diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 61be93aa3..f6df1d688 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -70,7 +70,6 @@ _Params: TypeAlias = Union[ str | bytes, ] _TextMapping: TypeAlias = MutableMapping[str, str] -_HeadersMapping: TypeAlias = Mapping[str, str | bytes] _HeadersUpdateMapping: TypeAlias = Mapping[str, str | bytes | None] _Timeout: TypeAlias = Union[float, tuple[float, float], tuple[float, None]] _Verify: TypeAlias = bool | str diff --git a/stubs/urllib3/urllib3/connection.pyi b/stubs/urllib3/urllib3/connection.pyi index f96e1640b..8baca880b 100644 --- a/stubs/urllib3/urllib3/connection.pyi +++ b/stubs/urllib3/urllib3/connection.pyi @@ -1,16 +1,12 @@ import ssl from builtins import ConnectionError as ConnectionError -from collections.abc import Iterable from http.client import HTTPConnection as _HTTPConnection, HTTPException as HTTPException -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import Any from . import exceptions, util from .packages import ssl_match_hostname from .util import ssl_ -_TYPE_BODY: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str - class DummyConnection: ... BaseSSLError = ssl.SSLError diff --git a/stubs/urllib3/urllib3/response.pyi b/stubs/urllib3/urllib3/response.pyi index cc7661c7d..f5b8d25cb 100644 --- a/stubs/urllib3/urllib3/response.pyi +++ b/stubs/urllib3/urllib3/response.pyi @@ -1,15 +1,16 @@ import io from _typeshed import Self -from collections.abc import Iterator, Mapping +from collections.abc import Iterable, Iterator, Mapping from http.client import HTTPMessage as _HttplibHTTPMessage, HTTPResponse as _HttplibHTTPResponse -from typing import Any -from typing_extensions import Literal +from typing import IO, Any +from typing_extensions import Literal, TypeAlias from urllib3.connectionpool import HTTPConnection from . import HTTPConnectionPool, Retry from ._collections import HTTPHeaderDict -from .connection import _TYPE_BODY + +_TYPE_BODY: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str class DeflateDecoder: def __init__(self) -> None: ...