Skip to content

Commit

Permalink
Avoid extra isinstance calls in _visit_generic (pylint-dev#2502)
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored Aug 7, 2024
1 parent 15207a7 commit 29b6cbd
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 @@ -104,11 +104,13 @@ def _visit_generic(
def _visit_generic(self, node: nodes.NodeNG) -> SuccessfulInferenceResult: ...

def _visit_generic(self, node: _Vistables) -> _VisitReturns:
if not node:
return node
if isinstance(node, list):
return [self._visit_generic(child) for child in node]
if isinstance(node, tuple):
return tuple(self._visit_generic(child) for child in node)
if not node or isinstance(node, str):
if isinstance(node, str):
return node

try:
Expand Down

0 comments on commit 29b6cbd

Please sign in to comment.