|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | from copy import copy
|
4 |
| -from typing import Generator |
| 4 | +from typing import Iterator |
5 | 5 |
|
6 | 6 | from mypy.nodes import (
|
7 | 7 | ParamSpecExpr,
|
|
10 | 10 | TypeVarLikeExpr,
|
11 | 11 | TypeVarTupleExpr,
|
12 | 12 | )
|
13 |
| -from mypy.type_visitor import SyntheticTypeVisitor, T |
| 13 | +from mypy.type_visitor import SyntheticTypeVisitor |
14 | 14 | from mypy.types import (
|
15 | 15 | AnyType,
|
16 | 16 | CallableArgument,
|
|
45 | 45 | )
|
46 | 46 |
|
47 | 47 |
|
48 |
| -class TypeVarLikeYielder(SyntheticTypeVisitor[Generator[TypeVarLikeType, None, None]]): |
| 48 | +class TypeVarLikeYielder(SyntheticTypeVisitor[Iterator[TypeVarLikeType]]): |
49 | 49 | """Yield all TypeVarLikeTypes in a type."""
|
50 | 50 |
|
51 |
| - def visit_type_var(self, t: TypeVarType) -> Generator[TypeVarLikeType, None, None]: |
| 51 | + def visit_type_var(self, t: TypeVarType) -> Iterator[TypeVarLikeType]: |
52 | 52 | yield t
|
53 | 53 |
|
54 |
| - def visit_type_var_tuple(self, t: TypeVarTupleType) -> Generator[TypeVarLikeType, None, None]: |
| 54 | + def visit_type_var_tuple(self, t: TypeVarTupleType) -> Iterator[TypeVarLikeType]: |
55 | 55 | yield t
|
56 | 56 |
|
57 |
| - def visit_param_spec(self, t: ParamSpecType) -> Generator[TypeVarLikeType, None, None]: |
| 57 | + def visit_param_spec(self, t: ParamSpecType) -> Iterator[TypeVarLikeType]: |
58 | 58 | yield t
|
59 | 59 |
|
60 |
| - def visit_callable_type(self, t: CallableType) -> Generator[TypeVarLikeType, None, None]: |
| 60 | + def visit_callable_type(self, t: CallableType) -> Iterator[TypeVarLikeType]: |
61 | 61 | for arg in t.arg_types:
|
62 | 62 | yield from arg.accept(self)
|
63 | 63 | yield from t.ret_type.accept(self)
|
64 | 64 |
|
65 |
| - def visit_instance(self, t: Instance) -> Generator[TypeVarLikeType, None, None]: |
| 65 | + def visit_instance(self, t: Instance) -> Iterator[TypeVarLikeType]: |
66 | 66 | for arg in t.args:
|
67 | 67 | yield from arg.accept(self)
|
68 | 68 |
|
69 |
| - def visit_overloaded(self, t: Overloaded) -> Generator[TypeVarLikeType, None, None]: |
| 69 | + def visit_overloaded(self, t: Overloaded) -> Iterator[TypeVarLikeType]: |
70 | 70 | for item in t.items:
|
71 | 71 | yield from item.accept(self)
|
72 | 72 |
|
73 |
| - def visit_tuple_type(self, t: TupleType) -> Generator[TypeVarLikeType, None, None]: |
| 73 | + def visit_tuple_type(self, t: TupleType) -> Iterator[TypeVarLikeType]: |
74 | 74 | for item in t.items:
|
75 | 75 | yield from item.accept(self)
|
76 | 76 |
|
77 |
| - def visit_type_alias_type(self, t: TypeAliasType) -> Generator[TypeVarLikeType, None, None]: |
| 77 | + def visit_type_alias_type(self, t: TypeAliasType) -> Iterator[TypeVarLikeType]: |
78 | 78 | for arg in t.args:
|
79 | 79 | yield from arg.accept(self)
|
80 | 80 |
|
81 |
| - def visit_typeddict_type(self, t: TypedDictType) -> Generator[TypeVarLikeType, None, None]: |
| 81 | + def visit_typeddict_type(self, t: TypedDictType) -> Iterator[TypeVarLikeType]: |
82 | 82 | for arg in t.items.values():
|
83 | 83 | yield from arg.accept(self)
|
84 | 84 |
|
85 |
| - def visit_union_type(self, t: UnionType) -> Generator[TypeVarLikeType, None, None]: |
| 85 | + def visit_union_type(self, t: UnionType) -> Iterator[TypeVarLikeType]: |
86 | 86 | for arg in t.items:
|
87 | 87 | yield from arg.accept(self)
|
88 | 88 |
|
89 |
| - def visit_type_type(self, t: TypeType) -> T: |
| 89 | + def visit_type_type(self, t: TypeType) -> Iterator[TypeVarLikeType]: |
90 | 90 | yield from t.item.accept(self)
|
91 | 91 |
|
92 |
| - def visit_star_type(self, t: StarType) -> T: |
| 92 | + def visit_star_type(self, t: StarType) -> Iterator[TypeVarLikeType]: |
93 | 93 | yield from ()
|
94 | 94 |
|
95 |
| - def visit_type_list(self, t: TypeList) -> T: |
| 95 | + def visit_type_list(self, t: TypeList) -> Iterator[TypeVarLikeType]: |
96 | 96 | yield from ()
|
97 | 97 |
|
98 |
| - def visit_callable_argument(self, t: CallableArgument) -> T: |
| 98 | + def visit_callable_argument(self, t: CallableArgument) -> Iterator[TypeVarLikeType]: |
99 | 99 | yield from ()
|
100 | 100 |
|
101 |
| - def visit_ellipsis_type(self, t: EllipsisType) -> T: |
| 101 | + def visit_ellipsis_type(self, t: EllipsisType) -> Iterator[TypeVarLikeType]: |
102 | 102 | yield from ()
|
103 | 103 |
|
104 |
| - def visit_raw_expression_type(self, t: RawExpressionType) -> T: |
| 104 | + def visit_raw_expression_type(self, t: RawExpressionType) -> Iterator[TypeVarLikeType]: |
105 | 105 | yield from ()
|
106 | 106 |
|
107 |
| - def visit_unbound_type(self, t: UnboundType) -> T: |
| 107 | + def visit_unbound_type(self, t: UnboundType) -> Iterator[TypeVarLikeType]: |
108 | 108 | yield from ()
|
109 | 109 |
|
110 |
| - def visit_none_type(self, t: NoneType) -> T: |
| 110 | + def visit_none_type(self, t: NoneType) -> Iterator[TypeVarLikeType]: |
111 | 111 | yield from ()
|
112 | 112 |
|
113 |
| - def visit_uninhabited_type(self, t: UninhabitedType) -> T: |
| 113 | + def visit_uninhabited_type(self, t: UninhabitedType) -> Iterator[TypeVarLikeType]: |
114 | 114 | yield from ()
|
115 | 115 |
|
116 |
| - def visit_erased_type(self, t: ErasedType) -> T: |
| 116 | + def visit_erased_type(self, t: ErasedType) -> Iterator[TypeVarLikeType]: |
117 | 117 | yield from ()
|
118 | 118 |
|
119 |
| - def visit_deleted_type(self, t: DeletedType) -> T: |
| 119 | + def visit_deleted_type(self, t: DeletedType) -> Iterator[TypeVarLikeType]: |
120 | 120 | yield from ()
|
121 | 121 |
|
122 |
| - def visit_parameters(self, t: Parameters) -> T: |
| 122 | + def visit_parameters(self, t: Parameters) -> Iterator[TypeVarLikeType]: |
123 | 123 | yield from ()
|
124 | 124 |
|
125 |
| - def visit_literal_type(self, t: LiteralType) -> T: |
| 125 | + def visit_literal_type(self, t: LiteralType) -> Iterator[TypeVarLikeType]: |
126 | 126 | yield from ()
|
127 | 127 |
|
128 |
| - def visit_partial_type(self, t: PartialType) -> T: |
| 128 | + def visit_partial_type(self, t: PartialType) -> Iterator[TypeVarLikeType]: |
129 | 129 | yield from ()
|
130 | 130 |
|
131 |
| - def visit_unpack_type(self, t: UnpackType) -> T: |
| 131 | + def visit_unpack_type(self, t: UnpackType) -> Iterator[TypeVarLikeType]: |
132 | 132 | yield from ()
|
133 | 133 |
|
134 |
| - def visit_any(self, t: AnyType) -> Generator[TypeVarLikeType, None, None]: |
| 134 | + def visit_any(self, t: AnyType) -> Iterator[TypeVarLikeType]: |
135 | 135 | yield from ()
|
136 | 136 |
|
137 |
| - def visit_placeholder_type(self, t: PlaceholderType) -> Generator[TypeVarLikeType, None, None]: |
| 137 | + def visit_placeholder_type(self, t: PlaceholderType) -> Iterator[TypeVarLikeType]: |
138 | 138 | yield from ()
|
139 | 139 |
|
140 | 140 |
|
|
0 commit comments