Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting AttributeError: 'Import' object has no attribute 'infer_name_module' on import #29

Closed
pmspire opened this issue Feb 27, 2019 · 3 comments

Comments

@pmspire
Copy link

pmspire commented Feb 27, 2019

Issue:

(base) ~ % conda create -y -n foo -c conda-forge --override-channels pylint >/dev/null
(base) ~ % conda activate foo
(foo) ~ % cat <<EOF >a.py
> import os
> EOF
(foo) ~ % pylint a.py
************* Module a
a.py:1:0: C0111: Missing module docstring (missing-docstring)
Traceback (most recent call last):
  File "/tmp/mc/envs/foo/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
    Run(sys.argv[1:])
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/lint.py", line 1608, in __init__
    linter.check(args)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/lint.py", line 938, in check
    self._do_check(files_or_modules)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/lint.py", line 1071, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/lint.py", line 1154, in check_astroid_module
    walker.walk(ast_node)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/utils.py", line 1269, in walk
    self.walk(child)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/utils.py", line 1266, in walk
    cb(astroid)
  File "/tmp/mc/envs/foo/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1582, in visit_import
    module = next(node.infer_name_module(parts[0]))
AttributeError: 'Import' object has no attribute 'infer_name_module'

Environment (conda list):
$ conda list
# packages in environment at /tmp/mc/envs/foo:
#
# Name                    Version                   Build  Channel
astroid                   2.2.0                    py37_0    conda-forge
bzip2                     1.0.6             h14c3975_1002    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py37_1000    conda-forge
isort                     4.3.9                    py37_0    conda-forge
lazy-object-proxy         1.3.1           py37h14c3975_1000    conda-forge
libffi                    3.2.1             hf484d3e_1005    conda-forge
libgcc-ng                 7.3.0                hdf63c60_0    conda-forge
libstdcxx-ng              7.3.0                hdf63c60_0    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
ncurses                   6.1               hf484d3e_1002    conda-forge
openssl                   1.1.1a            h14c3975_1000    conda-forge
pip                       19.0.3                   py37_0    conda-forge
pylint                    2.2.2                 py37_1000    conda-forge
python                    3.7.1             h381d211_1002    conda-forge
readline                  7.0               hf8c457e_1001    conda-forge
setuptools                40.8.0                   py37_0    conda-forge
six                       1.12.0                py37_1000    conda-forge
sqlite                    3.26.0            h67949de_1000    conda-forge
tk                        8.6.9             h84994c4_1000    conda-forge
wheel                     0.33.1                   py37_0    conda-forge
wrapt                     1.11.1           py37h14c3975_0    conda-forge
xz                        5.2.4             h14c3975_1001    conda-forge
zlib                      1.2.11            h14c3975_1004    conda-forge

Details about conda and system ( conda info ):
$ conda info

     active environment : foo
    active env location : /tmp/mc/envs/foo
            shell level : 2
       user config file : /home/pmadden/.condarc
 populated config files : 
          conda version : 4.6.7
    conda-build version : not installed
         python version : 3.7.2.final.0
       base environment : /tmp/mc  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /tmp/mc/pkgs
                          /home/pmadden/.conda/pkgs
       envs directories : /tmp/mc/envs
                          /home/pmadden/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.7 requests/2.21.0 CPython/3.7.2 Linux/4.15.0-45-generic ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : /home/pmadden/.netrc
           offline mode : False

@pmspire
Copy link
Author

pmspire commented Feb 27, 2019

If I pin astroid=2.1.0 to avoid installation of 2.2.0, I can avoid this error. Since astroid was updated 8 hours ago, it seems like the problem might be there.

@pmspire
Copy link
Author

pmspire commented Mar 1, 2019

I can no longer reproduce this, closing.

@pmspire pmspire closed this as completed Mar 1, 2019
@jjhelmus
Copy link
Contributor

jjhelmus commented Mar 2, 2019

I believe this was fixed in Pylint 2.3.0.

c.f. pylint-dev/astroid#649

mristin added a commit to Parquery/pyicontract-lint that referenced this issue Aug 22, 2020
The pylint had to be updated to 2.6.0 since its dependencies
got broken (such as isort).

See also:
PyCQA/isort#1273
conda-forge/pylint-feedstock#29
mristin added a commit to Parquery/pyicontract-lint that referenced this issue Aug 22, 2020
The pylint had to be updated to 2.6.0 since its dependencies
got broken (such as isort).

See also:
PyCQA/isort#1273
conda-forge/pylint-feedstock#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants