Skip to content

Commit 16990fc

Browse files
authored
Remove unnecessary isinstance calls from transform predicates (#2507)
1 parent 0cf9a2e commit 16990fc

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

astroid/brain/brain_numpy_ndarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def __class_getitem__(cls, value):
151151
return node.infer(context=context)
152152

153153

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

157157

158158
def register(manager: AstroidManager) -> None:

astroid/brain/brain_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
from astroid.manager import AstroidManager
2929

3030

31-
def _looks_like_type_subscript(node) -> bool:
31+
def _looks_like_type_subscript(node: nodes.Name) -> bool:
3232
"""
3333
Try to figure out if a Name node is used inside a type related subscript.
3434
3535
:param node: node to check
3636
:type node: astroid.nodes.node_classes.NodeNG
3737
:return: whether the node is a Name node inside a type related subscript
3838
"""
39-
if isinstance(node, nodes.Name) and isinstance(node.parent, nodes.Subscript):
39+
if isinstance(node.parent, nodes.Subscript):
4040
return node.name == "type"
4141
return False
4242

astroid/brain/brain_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def infer_special_alias(
398398

399399

400400
def _looks_like_typing_cast(node: Call) -> bool:
401-
return isinstance(node, Call) and (
401+
return (
402402
isinstance(node.func, Name)
403403
and node.func.name == "cast"
404404
or isinstance(node.func, Attribute)

0 commit comments

Comments
 (0)