28
28
Const ,
29
29
JoinedStr ,
30
30
Name ,
31
- NodeNG ,
32
31
Subscript ,
33
32
Tuple ,
34
33
)
@@ -380,36 +379,6 @@ def infer_special_alias(
380
379
return iter ([class_def ])
381
380
382
381
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
-
413
382
AstroidManager ().register_transform (
414
383
Call ,
415
384
inference_tip (infer_typing_typevar_or_newtype ),
@@ -418,9 +387,6 @@ def infer_typing_cast(
418
387
AstroidManager ().register_transform (
419
388
Subscript , inference_tip (infer_typing_attr ), _looks_like_typing_subscript
420
389
)
421
- AstroidManager ().register_transform (
422
- Call , inference_tip (infer_typing_cast ), _looks_like_typing_cast
423
- )
424
390
425
391
if PY39_PLUS :
426
392
AstroidManager ().register_transform (
0 commit comments