@@ -52,7 +52,7 @@ def __args__(self):
5252class {0}(metaclass=Meta):
5353 pass
5454"""
55- TYPING_MEMBERS = set (typing . __all__ )
55+ TYPING_MEMBERS = set (getattr ( typing , " __all__" , []) )
5656
5757TYPING_ALIAS = frozenset (
5858 (
@@ -144,7 +144,7 @@ def _looks_like_typing_subscript(node):
144144
145145
146146def infer_typing_attr (
147- node : Subscript , ctx : context .InferenceContext = None
147+ node : Subscript , ctx : typing . Optional [ context .InferenceContext ] = None
148148) -> typing .Iterator [ClassDef ]:
149149 """Infer a typing.X[...] subscript"""
150150 try :
@@ -179,7 +179,7 @@ def infer_typing_attr(
179179 ):
180180 # node.parent.slots is evaluated and cached before the inference tip
181181 # 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
183183 if cache .get (node .parent .slots ) is not None :
184184 del cache [node .parent .slots ]
185185 return iter ([value ])
@@ -196,15 +196,15 @@ def _looks_like_typedDict( # pylint: disable=invalid-name
196196
197197
198198def infer_old_typedDict ( # pylint: disable=invalid-name
199- node : ClassDef , ctx : context .InferenceContext = None
199+ node : ClassDef , ctx : typing . Optional [ context .InferenceContext ] = None
200200) -> typing .Iterator [ClassDef ]:
201201 func_to_add = extract_node ("dict" )
202202 node .locals ["__call__" ] = [func_to_add ]
203203 return iter ([node ])
204204
205205
206206def infer_typedDict ( # pylint: disable=invalid-name
207- node : FunctionDef , ctx : context .InferenceContext = None
207+ node : FunctionDef , ctx : typing . Optional [ context .InferenceContext ] = None
208208) -> typing .Iterator [ClassDef ]:
209209 """Replace TypedDict FunctionDef with ClassDef."""
210210 class_def = ClassDef (
@@ -264,7 +264,7 @@ def full_raiser(origin_func, attr, *args, **kwargs):
264264
265265
266266def infer_typing_alias (
267- node : Call , ctx : context .InferenceContext = None
267+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
268268) -> typing .Iterator [ClassDef ]:
269269 """
270270 Infers the call to _alias function
@@ -352,7 +352,7 @@ def _looks_like_special_alias(node: Call) -> bool:
352352
353353
354354def infer_special_alias (
355- node : Call , ctx : context .InferenceContext = None
355+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
356356) -> typing .Iterator [ClassDef ]:
357357 """Infer call to tuple alias as new subscriptable class typing.Tuple."""
358358 if not (
@@ -387,7 +387,7 @@ def _looks_like_typing_cast(node: Call) -> bool:
387387
388388
389389def infer_typing_cast (
390- node : Call , ctx : context .InferenceContext = None
390+ node : Call , ctx : typing . Optional [ context .InferenceContext ] = None
391391) -> typing .Iterator [NodeNG ]:
392392 """Infer call to cast() returning same type as casted-from var"""
393393 if not isinstance (node .func , (Name , Attribute )):
0 commit comments