diff options
| author | hippo91 <guillaume.peillex@gmail.com> | 2019-12-26 10:52:36 +0100 |
|---|---|---|
| committer | hippo91 <guillaume.peillex@gmail.com> | 2019-12-26 10:52:36 +0100 |
| commit | b697d54da14b9ae978e9fb166a52af70bce0693c (patch) | |
| tree | 522334b5efc4ba210aa770b19588c3c59efa5a7f | |
| parent | 1344a1cb42b17c644116cc2f50d54b37ac07167f (diff) | |
| download | astroid-git-b697d54da14b9ae978e9fb166a52af70bce0693c.tar.gz | |
The method looks_like_numpy_member is able to deal with astroid.Name nodes
| -rw-r--r-- | astroid/brain/brain_numpy_utils.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/astroid/brain/brain_numpy_utils.py b/astroid/brain/brain_numpy_utils.py index 2bad01ee..250f4893 100644 --- a/astroid/brain/brain_numpy_utils.py +++ b/astroid/brain/brain_numpy_utils.py @@ -48,9 +48,13 @@ def looks_like_numpy_member( :param node: node to test :return: True if the node is a member of numpy """ - return ( - isinstance(node, astroid.Attribute) + if (isinstance(node, astroid.Attribute) and node.attrname == member_name and isinstance(node.expr, astroid.Name) - and _is_a_numpy_module(node.expr) - ) + 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 |
