You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: tests/imports.pyi
+9-2
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,6 @@ from typing import (
84
84
NewType,
85
85
NoReturn,
86
86
overload,
87
-
ContextManager# ContextManager must be importable from typing (but not typing_extensions) for Python 2 compabitility
88
87
)
89
88
fromtyping_extensionsimport (
90
89
Concatenate,
@@ -97,7 +96,6 @@ from typing_extensions import (
97
96
TypeGuard,
98
97
Annotated,
99
98
TypedDict,
100
-
OrderedDict# OrderedDict must be importable from typing_extensions (but not typing) for Python 2 compatibility
101
99
)
102
100
103
101
@@ -116,6 +114,11 @@ from typing_extensions import ClassVar # Y023 Use "typing.ClassVar" instead of
116
114
fromtyping_extensionsimportAwaitable# Y023 Use "typing.Awaitable" instead of "typing_extensions.Awaitable"
117
115
fromtyping_extensionsimportContextManager# Y023 Use "contextlib.AbstractContextManager" (or "typing.ContextManager" in Python 2-compatible code) instead of "typing_extensions.ContextManager"
118
116
117
+
# BAD IMPORTS (Y027 code)
118
+
fromtypingimportContextManager# Y027 Use "contextlib.AbstractContextManager" instead of "typing.ContextManager"
119
+
fromtypingimportOrderedDict# Y027 Use "collections.OrderedDict" instead of "typing.OrderedDict"
120
+
fromtyping_extensionsimportOrderedDict# Y027 Use "collections.OrderedDict" instead of "typing_extensions.OrderedDict"
121
+
119
122
# BAD IMPORTS: OTHER
120
123
fromcollectionsimportnamedtuple# Y024 Use "typing.NamedTuple" instead of "collections.namedtuple"
121
124
fromcollections.abcimportSet# Y025 Use "from collections.abc import Set as AbstractSet" to avoid confusion with "builtins.set"
@@ -169,5 +172,9 @@ class Foo:
169
172
h: typing_extensions.Awaitable[float] # Y023 Use "typing.Awaitable" instead of "typing_extensions.Awaitable"
170
173
i: typing_extensions.ContextManager[None] # Y023 Use "contextlib.AbstractContextManager" (or "typing.ContextManager" in Python 2-compatible code) instead of "typing_extensions.ContextManager"
171
174
175
+
# BAD ATTRIBUTE ACCESS (Y027 code)
176
+
k: typing_extensions.OrderedDict[int, str] # Y027 Use "collections.OrderedDict" instead of "typing_extensions.OrderedDict"
177
+
l: typing.ContextManager# Y027 Use "contextlib.AbstractContextManager" instead of "typing.ContextManager"
178
+
172
179
# BAD ATTRIBUTE ACCESS: OTHER
173
180
j: collections.namedtuple# Y024 Use "typing.NamedTuple" instead of "collections.namedtuple"
0 commit comments