Skip to content

Commit

Permalink
Remove unnecessary isinstance calls from transform predicates (pylint…
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored Aug 27, 2024
1 parent 0cf9a2e commit 16990fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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

0 comments on commit 16990fc

Please sign in to comment.