2828 Const ,
2929 JoinedStr ,
3030 Name ,
31- NodeNG ,
3231 Subscript ,
3332 Tuple ,
3433)
@@ -380,36 +379,6 @@ def infer_special_alias(
380379 return iter ([class_def ])
381380
382381
383- def _looks_like_typing_cast (node : Call ) -> bool :
384- return isinstance (node , Call ) and (
385- isinstance (node .func , Name )
386- and node .func .name == "cast"
387- or isinstance (node .func , Attribute )
388- and node .func .attrname == "cast"
389- )
390-
391-
392- def infer_typing_cast (
393- node : Call , ctx : context .InferenceContext | None = None
394- ) -> Iterator [NodeNG ]:
395- """Infer call to cast() returning same type as casted-from var."""
396- if not isinstance (node .func , (Name , Attribute )):
397- raise UseInferenceDefault
398-
399- try :
400- func = next (node .func .infer (context = ctx ))
401- except (InferenceError , StopIteration ) as exc :
402- raise UseInferenceDefault from exc
403- if (
404- not isinstance (func , FunctionDef )
405- or func .qname () != "typing.cast"
406- or len (node .args ) != 2
407- ):
408- raise UseInferenceDefault
409-
410- return node .args [1 ].infer (context = ctx )
411-
412-
413382AstroidManager ().register_transform (
414383 Call ,
415384 inference_tip (infer_typing_typevar_or_newtype ),
@@ -418,9 +387,6 @@ def infer_typing_cast(
418387AstroidManager ().register_transform (
419388 Subscript , inference_tip (infer_typing_attr ), _looks_like_typing_subscript
420389)
421- AstroidManager ().register_transform (
422- Call , inference_tip (infer_typing_cast ), _looks_like_typing_cast
423- )
424390
425391if PY39_PLUS :
426392 AstroidManager ().register_transform (
0 commit comments