Skip to content

Commit

Permalink
Avoid overhead of cast() calls when not type checking (#2500)
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored Aug 7, 2024
1 parent 29b6cbd commit 0156c04
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion astroid/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def _transform(self, node: SuccessfulInferenceResult) -> SuccessfulInferenceResu
def _visit(self, node: nodes.NodeNG) -> SuccessfulInferenceResult:
for name in node._astroid_fields:
value = getattr(node, name)
value = cast(_Vistables, value)
if TYPE_CHECKING:
value = cast(_Vistables, value)

visited = self._visit_generic(value)
if visited != value:
setattr(node, name, visited)
Expand Down

0 comments on commit 0156c04

Please sign in to comment.