@@ -52,7 +52,7 @@ def __args__(self):
52
52
class {0}(metaclass=Meta):
53
53
pass
54
54
"""
55
- TYPING_MEMBERS = set (typing . __all__ )
55
+ TYPING_MEMBERS = set (getattr ( typing , " __all__" , []) )
56
56
57
57
TYPING_ALIAS = frozenset (
58
58
(
@@ -144,7 +144,7 @@ def _looks_like_typing_subscript(node):
144
144
145
145
146
146
def infer_typing_attr (
147
- node : Subscript , ctx : context .InferenceContext = None
147
+ node : Subscript , ctx : typing . Optional [ context .InferenceContext ] = None
148
148
) -> typing .Iterator [ClassDef ]:
149
149
"""Infer a typing.X[...] subscript"""
150
150
try :
@@ -179,7 +179,7 @@ def infer_typing_attr(
179
179
):
180
180
# node.parent.slots is evaluated and cached before the inference tip
181
181
# is first applied. Remove the last result to allow a recalculation of slots
182
- cache = node .parent .__cache
182
+ cache = node .parent .__cache # type: ignore[attr-defined] # Unrecognized getattr
183
183
if cache .get (node .parent .slots ) is not None :
184
184
del cache [node .parent .slots ]
185
185
return iter ([value ])
@@ -196,15 +196,15 @@ def _looks_like_typedDict( # pylint: disable=invalid-name
196
196
197
197
198
198
def infer_old_typedDict ( # pylint: disable=invalid-name
199
- node : ClassDef , ctx : context .InferenceContext = None
199
+ node : ClassDef , ctx : typing . Optional [ context .InferenceContext ] = None
200
200
) -> typing .Iterator [ClassDef ]:
201
201
func_to_add = extract_node ("dict" )
202
202
node .locals ["__call__" ] = [func_to_add ]
203
203
return iter ([node ])
204
204
205
205
206
206
def infer_typedDict ( # pylint: disable=invalid-name
207
- node : FunctionDef , ctx : context .InferenceContext = None
207
+ node : FunctionDef , ctx : typing . Optional [ context .InferenceContext ] = None
208
208
) -> typing .Iterator [ClassDef ]:
209
209
"""Replace TypedDict FunctionDef with ClassDef."""
210
210
class_def = ClassDef (
@@ -264,7 +264,7 @@ def full_raiser(origin_func, attr, *args, **kwargs):
264
264
265
265
266
266
def infer_typing_alias (
267
- node : Call , ctx : context .InferenceContext = None
267
+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
268
268
) -> typing .Iterator [ClassDef ]:
269
269
"""
270
270
Infers the call to _alias function
@@ -352,7 +352,7 @@ def _looks_like_special_alias(node: Call) -> bool:
352
352
353
353
354
354
def infer_special_alias (
355
- node : Call , ctx : context .InferenceContext = None
355
+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
356
356
) -> typing .Iterator [ClassDef ]:
357
357
"""Infer call to tuple alias as new subscriptable class typing.Tuple."""
358
358
if not (
@@ -387,7 +387,7 @@ def _looks_like_typing_cast(node: Call) -> bool:
387
387
388
388
389
389
def infer_typing_cast (
390
- node : Call , ctx : context .InferenceContext = None
390
+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
391
391
) -> typing .Iterator [NodeNG ]:
392
392
"""Infer call to cast() returning same type as casted-from var"""
393
393
if not isinstance (node .func , (Name , Attribute )):
0 commit comments