Pylint: AttributeError: 'ImportFrom' object has no attribute 'name'

Created on 16 Dec 2017  路  8Comments  路  Source: PyCQA/pylint

Steps to reproduce

  1. Create file:
from os import makedirs
def makedirs():
    pass
  1. Run pylint newfile.py

Current behavior

Traceback (most recent call last):
  File "/Users/jacques/miniconda/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/lint.py", line 1347, in __init__
    linter.check(args)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/lint.py", line 768, in check
    self._do_check(files_or_modules)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/lint.py", line 901, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/lint.py", line 980, in check_astroid_module
    walker.walk(ast_node)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/utils.py", line 1014, in walk
    self.walk(child)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/utils.py", line 1011, in walk
    cb(astroid)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/checkers/base.py", line 505, in visit_functiondef
    self._check_redefinition(node.is_method() and 'method' or 'function', node)
  File "/Users/jacques/miniconda/lib/python3.6/site-packages/pylint/checkers/base.py", line 717, in _check_redefinition
    if dummy_variables_rgx and dummy_variables_rgx.match(defined_self.name):
AttributeError: 'ImportFrom' object has no attribute 'name'

Expected behavior

No exception

pylint --version output

No config file found, using default configuration
pylint 1.8.1,
astroid 1.6.0
Python 3.6.3 | packaged by conda-forge | (default, Dec  9 2017, 16:20:51)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]

Extra

Seems like https://github.com/PyCQA/pylint/pull/1665 might be the source of this. Maybe the line just needs to be:

if dummy_variables_rgx and dummy_variables_rgx.match(defined_self.names[0][0]):
bug

Most helpful comment

When I'll have time. Unfortunately I'm a bit busy at the moment, but hopefully I'll find some time in the weekend for a new release

All 8 comments

+1 Same here, problem with ImportForm and name attribute

File "/usr/local/lib/python2.7/dist-packages/django_jenkins/tasks/run_pylint.py", line 44, in run
lint.Run(args, reporter=ParseableTextReporter(output=output), exit=False)
File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 1347, in __init__
linter.check(args)
File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 768, in check
self._do_check(files_or_modules)
File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 901, in _do_check
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 980, in check_astroid_module
walker.walk(ast_node)
File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 1014, in walk
self.walk(child)
File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 1011, in walk
cb(astroid)
File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/base.py", line 463, in visit_classdef
self._check_redefinition('class', node)
File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/base.py", line 717, in _check_redefinition
if dummy_variables_rgx and dummy_variables_rgx.match(defined_self.name):
AttributeError: 'ImportFrom' object has no attribute 'name'

Same thing here. I was going to open the very same issue. My MWE was:

~py
from argparse import ArgumentParser
class ArgumentParser:
pass
~

Given the original message of this thread, I think that the bug arises when one redefines an existing function/class.

Good luck! 馃檪

Thanks for the report!

@PCManticore is this currently in the 1.8.1 version? I am still getting this error at the moment

@ransom4real it's not in any released versions, you'll need to use 1.8 or master branches I believe. I'm using the 1.8 branch myself.

Do you know when it will be released in a next version? (thanks for the work anyway!)

When I'll have time. Unfortunately I'm a bit busy at the moment, but hopefully I'll find some time in the weekend for a new release

@PCManticore ok thank you :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TBoshoven picture TBoshoven  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments

elirnm picture elirnm  路  3Comments

jrial picture jrial  路  3Comments