Skip to content

Commit

Permalink
Remove redundant isinstance calls in brain_typing
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored and Pierre-Sassoulas committed Jul 20, 2021
1 parent 8bf4f17 commit 42bb0c6
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions astroid/brain/brain_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ def _looks_like_typing_alias(node: Call) -> bool:
:param node: call node
"""
return (
isinstance(node, Call)
and isinstance(node.func, Name)
isinstance(node.func, Name)
and node.func.name == "_alias"
and (
# _alias function works also for builtins object such as list and dict
Expand Down Expand Up @@ -327,19 +326,15 @@ def _looks_like_tuple_alias(node: Call) -> bool:
PY37: Tuple = _VariadicGenericAlias(tuple, (), inst=False, special=True)
PY39: Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
"""
return (
isinstance(node, Call)
and isinstance(node.func, Name)
and (
not PY39_PLUS
and node.func.name == "_VariadicGenericAlias"
and isinstance(node.args[0], Name)
and node.args[0].name == "tuple"
or PY39_PLUS
and node.func.name == "_TupleType"
and isinstance(node.args[0], Name)
and node.args[0].name == "tuple"
)
return isinstance(node.func, Name) and (
not PY39_PLUS
and node.func.name == "_VariadicGenericAlias"
and isinstance(node.args[0], Name)
and node.args[0].name == "tuple"
or PY39_PLUS
and node.func.name == "_TupleType"
and isinstance(node.args[0], Name)
and node.args[0].name == "tuple"
)


Expand Down

0 comments on commit 42bb0c6

Please sign in to comment.