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/aliases.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ from collections.abc import Mapping
7
7
fromtypingimport (
8
8
Annotated,
9
9
Any,
10
+
Literal,
10
11
Optional,
11
12
ParamSpecas_ParamSpec,
12
13
TypeAlias,
@@ -17,7 +18,6 @@ from typing import (
17
18
fromweakrefimportWeakValueDictionary
18
19
19
20
importtyping_extensions
20
-
fromtyping_extensionsimportLiteral
21
21
22
22
classFoo:
23
23
defbaz(self) ->None: ...
@@ -33,7 +33,7 @@ S = Optional[str] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g.
33
33
T=Annotated[int, "some very useful metadata"] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "T: TypeAlias = Annotated[int, 'some very useful metadata']"
34
34
U=typing.Literal["ham", "bacon"] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "U: TypeAlias = typing.Literal['ham', 'bacon']"
35
35
V=Literal["[(", ")]"] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "V: TypeAlias = Literal['[(', ')]']"
36
-
X=typing_extensions.Literal["foo", "bar"] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "X: TypeAlias = typing_extensions.Literal['foo', 'bar']"
36
+
X=typing_extensions.Literal["foo", "bar"] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "X: TypeAlias = typing_extensions.Literal['foo', 'bar']" # Y023 Use "typing.Literal" instead of "typing_extensions.Literal"
37
37
Y=int|str# Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "Y: TypeAlias = int | str"
38
38
Z=Union[str, bytes] # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "Z: TypeAlias = Union[str, bytes]"
39
39
ZZ=None# Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "ZZ: TypeAlias = None"
Copy file name to clipboardExpand all lines: tests/calls.pyi
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ class V(NamedTuple):
15
15
# BAD TYPEDDICTS
16
16
W=TypedDict("W", {'foo': str, 'bar': int}) # Y031 Use class-based syntax for TypedDicts where possible
17
17
B=typing.TypedDict("B", {'foo': str, 'bar': int}) # Y031 Use class-based syntax for TypedDicts where possible
18
-
WithTotal=typing_extensions.TypedDict("WithTotal", {'foo': str, 'bar': int}, total=False) # Y031 Use class-based syntax for TypedDicts where possible
18
+
WithTotal=typing_extensions.TypedDict("WithTotal", {'foo': str, 'bar': int}, total=False) # Y023 Use "typing.TypedDict" instead of "typing_extensions.TypedDict" # Y031 Use class-based syntax for TypedDicts where possible
19
19
BB=mypy_extensions.TypedDict("BB", {'foo': str, 'bar': int}) # Y031 Use class-based syntax for TypedDicts where possible
20
20
21
21
# we don't want these two to raise errors (type-checkers already do that for us),
deff14_union(x: Union[typing_extensions.Type[int], typing_extensions.Type[str]]) ->None: ... # Y022 Use "type[MyClass]" instead of "typing_extensions.Type[MyClass]" (PEP 585 syntax) # Y022 Use "type[MyClass]" instead of "typing_extensions.Type[MyClass]" (PEP 585 syntax)
50
50
51
51
just_literals_subscript_union: Union[Literal[1], typing.Literal[2]] # Y030 Multiple Literal members in a union. Use a single Literal, e.g. "Literal[1, 2]".
52
-
mixed_subscript_union: Union[bytes, Literal['foo'], typing_extensions.Literal['bar']] # Y030 Multiple Literal members in a union. Combine them into one, e.g. "Literal['foo', 'bar']".
52
+
mixed_subscript_union: Union[bytes, Literal['foo'], typing_extensions.Literal['bar']] # Y030 Multiple Literal members in a union. Combine them into one, e.g. "Literal['foo', 'bar']". # Y023 Use "typing.Literal" instead of "typing_extensions.Literal"
53
53
just_literals_pipe_union: TypeAlias=Literal[True] |Literal['idk'] # Y042 Type aliases should use the CamelCase naming convention # Y030 Multiple Literal members in a union. Use a single Literal, e.g. "Literal[True, 'idk']".
54
54
_mixed_pipe_union: TypeAlias=Union[Literal[966], bytes, Literal['baz']] # Y042 Type aliases should use the CamelCase naming convention # Y047 Type alias "_mixed_pipe_union" is not used # Y030 Multiple Literal members in a union. Combine them into one, e.g. "Literal[966, 'baz']".
55
55
ManyLiteralMembersButNeedsCombining: TypeAlias=int|Literal['a', 'b'] |Literal['baz'] # Y030 Multiple Literal members in a union. Combine them into one, e.g. "Literal['a', 'b', 'baz']".
class_UnusedTypedDict(TypedDict): # Y049 TypedDict "_UnusedTypedDict" is not used
42
42
foo: str
43
43
44
-
class_UnusedTypedDict2(typing_extensions.TypedDict): # Y049 TypedDict "_UnusedTypedDict2" is not used
44
+
class_UnusedTypedDict2(typing_extensions.TypedDict): # Y049 TypedDict "_UnusedTypedDict2" is not used # Y023 Use "typing.TypedDict" instead of "typing_extensions.TypedDict"
45
45
bar: int
46
46
47
47
class_UnusedTypedDict3(mypy_extensions.TypedDict): # Y049 TypedDict "_UnusedTypedDict3" is not used
@@ -59,7 +59,7 @@ class _UsedTypedDict2(TypedDict):
_UnusedTypedDict4=TypedDict("_UnusedTypedDict4", {"-": int, "def": str}) # Y049 TypedDict "_UnusedTypedDict4" is not used
62
-
_UnusedTypedDict5=typing_extensions.TypedDict("_UnusedTypedDict5", {"foo": bytes, "bar": str}) # Y049 TypedDict "_UnusedTypedDict5" is not used # Y031 Use class-based syntax for TypedDicts where possible
62
+
_UnusedTypedDict5=typing_extensions.TypedDict("_UnusedTypedDict5", {"foo": bytes, "bar": str}) # Y049 TypedDict "_UnusedTypedDict5" is not used # Y023 Use "typing.TypedDict" instead of "typing_extensions.TypedDict" # Y031 Use class-based syntax for TypedDicts where possible
0 commit comments