Skip to content

Commit

Permalink
Merge c72c8e2 into 67321ee
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo91 committed Jan 5, 2020
2 parents 67321ee + c72c8e2 commit e5cc5d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Expand Up @@ -6,6 +6,12 @@ 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 to the ``brain_numpy_core_umath`` module

Close PyCQA/pylint#3319
Expand Down
5 changes: 5 additions & 0 deletions astroid/brain/brain_numpy_core_multiarray.py
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
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 e5cc5d0

Please sign in to comment.