Skip to content

Commit 5c6178a

Browse files
authored
Import generics from standard modules in all third-party stubs (#7791)
1 parent 6c6c669 commit 5c6178a

File tree

26 files changed

+76
-59
lines changed

26 files changed

+76
-59
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
# F405 defined from star imports
1919

2020
# Rules that we'd like to enable in the future:
21-
# Y027 Disallow importing typing.ContextManager, typing.OrderedDict &
22-
# typing_extensions.OrderedDict (cannot be globally enabled while typeshed
23-
# still contains stubs supporting Python 2).
2421
# Y034 Detect common errors where certain methods are annotated as having a fixed
2522
# return type, despite returning self at runtime (temporarily disabled for
2623
# typing.pyi, enabled elsewhere).
@@ -36,7 +33,6 @@ per-file-ignores =
3633
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
3734
# https://github.com/PyCQA/flake8/issues/1079
3835
# F811 redefinition of unused '...'
39-
stubs/*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y027, Y037
4036
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y034, Y037
4137

4238
exclude = .venv*,.git,*_pb2.pyi,stdlib/@python2/*

stubs/Deprecated/deprecated/classic.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Callable, TypeVar, overload
1+
from collections.abc import Callable
2+
from typing import Any, TypeVar, overload
23
from typing_extensions import Literal, TypeAlias
34

45
_F = TypeVar("_F", bound=Callable[..., Any])

stubs/Deprecated/deprecated/sphinx.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Callable, TypeVar
1+
from collections.abc import Callable
2+
from typing import Any, TypeVar
23
from typing_extensions import Literal
34

45
from .classic import ClassicAdapter, _Actions

stubs/Flask-Cors/flask_cors/decorator.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from collections.abc import Callable
1+
from collections.abc import Callable, Iterable
22
from datetime import timedelta
33
from logging import Logger
4-
from typing import Any, Iterable, Pattern
4+
from typing import Any, Pattern
55
from typing_extensions import ParamSpec
66

77
_P = ParamSpec("_P")

stubs/SQLAlchemy/sqlalchemy/orm/query.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Self
2-
from typing import Any, Generic, Iterator, TypeVar
2+
from collections.abc import Iterator
3+
from typing import Any, Generic, TypeVar
34

45
from ..sql.annotation import SupportsCloneAnnotations
56
from ..sql.base import Executable
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
from _typeshed import StrOrBytesPath
22
from collections.abc import Callable
3-
from typing import IO, Any, AnyStr, ContextManager
3+
from contextlib import AbstractContextManager
4+
from typing import IO, Any, AnyStr
45

56
def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ...
67
def move_atomic(src: AnyStr, dst: AnyStr) -> None: ...
78

89
class AtomicWriter:
910
def __init__(self, path: StrOrBytesPath, mode: str = ..., overwrite: bool = ...) -> None: ...
10-
def open(self) -> ContextManager[IO[Any]]: ...
11-
def _open(self, get_fileobject: Callable[..., IO[AnyStr]]) -> ContextManager[IO[AnyStr]]: ...
11+
def open(self) -> AbstractContextManager[IO[Any]]: ...
12+
def _open(self, get_fileobject: Callable[..., IO[AnyStr]]) -> AbstractContextManager[IO[AnyStr]]: ...
1213
def get_fileobject(self, dir: StrOrBytesPath | None = ..., **kwargs: Any) -> IO[Any]: ...
1314
def sync(self, f: IO[Any]) -> None: ...
1415
def commit(self, f: IO[Any]) -> None: ...
1516
def rollback(self, f: IO[Any]) -> None: ...
1617

17-
def atomic_write(path: StrOrBytesPath, writer_cls: type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ...
18+
def atomic_write(
19+
path: StrOrBytesPath, writer_cls: type[AtomicWriter] = ..., **cls_kwargs: object
20+
) -> AbstractContextManager[IO[Any]]: ...

stubs/characteristic/characteristic/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, AnyStr, Callable, Sequence, TypeVar
1+
from collections.abc import Callable, Sequence
2+
from typing import Any, AnyStr, TypeVar
23

34
def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ...
45
def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ...

stubs/colorama/colorama/ansitowin32.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
22
from _typeshed import SupportsWrite
3+
from collections.abc import Callable, Sequence
34
from types import TracebackType
4-
from typing import Any, Callable, Pattern, Sequence, TextIO
5+
from typing import Any, Pattern, TextIO
56
from typing_extensions import TypeAlias
67

78
if sys.platform == "win32":

stubs/colorama/colorama/initialise.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ContextManager, TextIO
1+
from contextlib import AbstractContextManager
2+
from typing import Any, TextIO
23

34
from .ansitowin32 import StreamWrapper
45

@@ -11,7 +12,7 @@ atexit_done: bool
1112
def reset_all() -> None: ...
1213
def init(autoreset: bool = ..., convert: bool | None = ..., strip: bool | None = ..., wrap: bool = ...) -> None: ...
1314
def deinit() -> None: ...
14-
def colorama_text(*args: Any, **kwargs: Any) -> ContextManager[None]: ...
15+
def colorama_text(*args: Any, **kwargs: Any) -> AbstractContextManager[None]: ...
1516
def reinit() -> None: ...
1617
def wrap_stream(
1718
stream: TextIO, convert: bool | None, strip: bool | None, autoreset: bool, wrap: bool

stubs/colorama/colorama/win32.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import Callable
2+
from collections.abc import Callable
33
from typing_extensions import Literal
44

55
STDOUT: Literal[-11]

0 commit comments

Comments
 (0)