Skip to content

Remove unnecessary isinstance calls from transform predicates #2507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions astroid/brain/brain_numpy_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def __class_getitem__(cls, value):
return node.infer(context=context)


def _looks_like_numpy_ndarray(node) -> bool:
return isinstance(node, Attribute) and node.attrname == "ndarray"
def _looks_like_numpy_ndarray(node: Attribute) -> bool:
return node.attrname == "ndarray"


def register(manager: AstroidManager) -> None:
Expand Down
4 changes: 2 additions & 2 deletions astroid/brain/brain_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
from astroid.manager import AstroidManager


def _looks_like_type_subscript(node) -> bool:
def _looks_like_type_subscript(node: nodes.Name) -> bool:
"""
Try to figure out if a Name node is used inside a type related subscript.

:param node: node to check
:type node: astroid.nodes.node_classes.NodeNG
:return: whether the node is a Name node inside a type related subscript
"""
if isinstance(node, nodes.Name) and isinstance(node.parent, nodes.Subscript):
if isinstance(node.parent, nodes.Subscript):
return node.name == "type"
return False

Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def infer_special_alias(


def _looks_like_typing_cast(node: Call) -> bool:
return isinstance(node, Call) and (
return (
isinstance(node.func, Name)
and node.func.name == "cast"
or isinstance(node.func, Attribute)
Expand Down
Loading