Skip to content

Commit

Permalink
Merge d487e0a into 1344a1c
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo91 committed Dec 28, 2019
2 parents 1344a1c + d487e0a commit 493301b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ What's New in astroid 2.4.0?
============================
Release Date: TBA

* Added a call to ``register_transform`` for all functions of the ``brain_numpy_core_multiarray``
module in case the current node is an instance of ``astroid.Name``

Close #666

* Added some functions of the ``numpy.core.multiarray`` module

Close PyCQA/pylint#3208
Expand Down
5 changes: 5 additions & 0 deletions astroid/brain/brain_numpy_core_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ def vdot(a, b):
astroid.inference_tip(inference_function),
functools.partial(looks_like_numpy_member, method_name),
)
astroid.MANAGER.register_transform(
astroid.Name,
astroid.inference_tip(inference_function),
functools.partial(looks_like_numpy_member, method_name),
)
12 changes: 10 additions & 2 deletions astroid/brain/brain_numpy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ def looks_like_numpy_member(
:param node: node to test
:return: True if the node is a member of numpy
"""
return (
if (
isinstance(node, astroid.Attribute)
and node.attrname == member_name
and isinstance(node.expr, astroid.Name)
and _is_a_numpy_module(node.expr)
)
):
return True
if (
isinstance(node, astroid.Name)
and node.name == member_name
and node.root().name.startswith("numpy")
):
return True
return False

0 comments on commit 493301b

Please sign in to comment.