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