pylint-dev / pylint-django

Pylint plugin for improving code analysis for when using Django
Other
593 stars 117 forks source link

AttributeError: 'AssignAttr' object has no attribute 'qname' #105

Closed alex-hutton closed 5 years ago

alex-hutton commented 7 years ago

I frequently, but not always, see AttributeError: 'AssignAttr' object has no attribute 'qname' when running pylint on my sourcecode.

Unfortunately I was unable to find any clues as to why this is happening. I have tried pylint 1.7.4 and pylint 1.6.5. I am using astroid 1.5.3.

Please advise how I can investigate this further.

See the attached backtrace: error (3).txt

chasingrainbows commented 6 years ago

+1 pylint 1.8.2

atodorov commented 6 years ago

@ChasingRainbows, @alex-hutton, can you post a pip freeze

atodorov commented 6 years ago

@ChasingRainbows , @alex-hutton can you post a code snippet that reproduces this with the latest pylint_django version ? The attached traceback doesn't call pylint_django anywhere in the stack so I will close this issue if we can't get a reproducer. Without a reproducer there's nothing more we can do.

nedbat commented 6 years ago

I can reproduce this error:

Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/usr/local/lib/python2.7/dist-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 1353, in __init__
    linter.check(args)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 774, in check
    self._do_check(files_or_modules)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 907, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 986, 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_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 138, in do_suppress
    chain()
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 138, in do_suppress
    chain()
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 138, in do_suppress
    chain()
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 138, in do_suppress
    chain()
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 138, in do_suppress
    chain()
  File "/usr/local/lib/python2.7/dist-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/classes.py", line 634, in visit_classdef
    self._check_bases_classes(node)
  File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/classes.py", line 1246, in _check_bases_classes
    unimplemented_abstract_methods(node, is_abstract).items(),
  File "/usr/local/lib/python2.7/dist-packages/backports/functools_lru_cache.py", line 137, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/utils.py", line 571, in unimplemented_abstract_methods
    infered = safe_infer(obj)
  File "/usr/local/lib/python2.7/dist-packages/backports/functools_lru_cache.py", line 137, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/utils.py", line 822, in safe_infer
    value = next(inferit)
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/usr/local/lib/python2.7/dist-packages/astroid/bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python2.7/dist-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/usr/local/lib/python2.7/dist-packages/astroid/inference.py", line 166, in infer_call
    for callee in self.func.infer(context):
  File "/usr/local/lib/python2.7/dist-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/usr/local/lib/python2.7/dist-packages/astroid/bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python2.7/dist-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 86, in wrapped
    generator = _func(node, context, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/astroid/inference.py", line 219, in infer_import_from
    module = self.do_import_module()
  File "/usr/local/lib/python2.7/dist-packages/astroid/mixins.py", line 119, in do_import_module
    relative_only=level and level >= 1)
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 599, in import_module
    return MANAGER.ast_from_module_name(modname)
  File "/usr/local/lib/python2.7/dist-packages/astroid/manager.py", line 154, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/usr/local/lib/python2.7/dist-packages/astroid/manager.py", line 80, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/usr/local/lib/python2.7/dist-packages/astroid/builder.py", line 153, in file_build
    return self._post_build(module, encoding)
  File "/usr/local/lib/python2.7/dist-packages/astroid/builder.py", line 173, in _post_build
    self.delayed_assattr(delayed)
  File "/usr/local/lib/python2.7/dist-packages/astroid/builder.py", line 232, in delayed_assattr
    for inferred in node.expr.infer():
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/usr/local/lib/python2.7/dist-packages/astroid/bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python2.7/dist-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/usr/local/lib/python2.7/dist-packages/astroid/decorators.py", line 86, in wrapped
    generator = _func(node, context, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/astroid/inference.py", line 760, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "/usr/local/lib/python2.7/dist-packages/astroid/protocols.py", line 304, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == 'metaclass'
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 1650, in _class_type
    if _is_metaclass(klass):
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 1636, in _is_metaclass
    if _is_metaclass(baseobj, seen):
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 1620, in _is_metaclass
    baseobj_name = baseobj.qname()
AttributeError: 'AssignAttr' object has no attribute 'qname'

This is with pylint==1.9.3 and git+https://github.com/PyCQA/pylint-django@backport_120_to_0.8

I have instructions for you to reproduce it also, though it is cumbersome. Our project is large, and uses hundreds of third-party packages. If I don't install them, the error doesn't happen. Here is a docker-based script to reproduce the crash:

cat > doit.sh <<EOF
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get update -q
apt-get install -q -y \
    git python2.7 python-dev python-pip locales build-essential gfortran \
    graphviz graphviz-dev liblapack-dev libmysqlclient-dev libxml2-dev \
    libgeos-dev libxslt1-dev gettext libjpeg8-dev libpng12-dev \
    libxmlsec1-dev swig s3cmd pkg-config g++ apparmor-utils \
    curl ipython nodejs ntp libfreetype6-dev libffi-dev python-dev \
    libsqlite3-dev
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
python -V
git clone https://github.com/edx/edx-platform.git
cd edx-platform
git checkout c119d387e184b2244040d2051bdd587c2f9fe46a
pip install -r requirements/edx/development.txt
pip freeze
pylint --output-format=parseable common/djangoapps/*
EOF
chmod +x doit.sh

docker run -it --init --rm -v `pwd`:/host ubuntu:xenial /host/doit.sh

If I try the same but without pylint-django, the crash doesn't happen. I don't see pylint-django in the traceback, but pylint-plugins is there.

atodorov commented 6 years ago

@nedbat thanks for the reproducer. I will try to update that and see if it reproduces with the latest version.

dgrant commented 5 years ago

I'm still seeing this problem, and it's somewhat random.

atodorov commented 5 years ago

@nedbat I can reproduce with your instructions but its pointless to try figuring this out because the versions you are using are rather old and we've made changes around this part of the code (IIRC).

qname is an astroid attribute which is related to inference. From the traceback it feels like we may be hitting some edge case here but I can't tell anything more without investing significant amount of time to debug and figure it out.

@dgrant, anyone else - can you post a reproducer which uses the latest versions of pylint-django and friends (Py3 only) ? I don't think there's anything else we can do about this issue until then.

dgrant commented 5 years ago

@atodorov I can't seem to reproduce any more now that I cleaned up my dependencies. Thanks.

atodorov commented 5 years ago

@dgrant thanks for following up.

I will close this for now. If anyone can reproduce with a recent version feel free to reopen.

GeeWee commented 5 years ago

I have this issue with 2.0.11 still, but I can't reproduce it. Running it on the same code, twice will sometimes provoke the error, but sometimes not.

ljodal commented 4 years ago

Hi there! We've started seeing this issue after upgrading to pylint 2.5.0. Here's the stacktrace we get. I've only ever seen it when running with multiple processes, but it's not happening every time, so it seems quite random:

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/check_parallel.py", line 69, in _worker_check_single_file
    _worker_linter.check_single_file(name, filepath, modname)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 890, in check_single_file
    self.get_ast, check_astroid_module, name, filepath, modname
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 1063, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint_django/checkers/models.py", line 81, in visit_classdef
    if not node_is_subclass(node, 'django.db.models.base.Model', '.Model'):
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint_django/utils.py", line 26, in node_is_subclass
    if inf != cls and node_is_subclass(inf, *subclass_names):
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint_django/utils.py", line 24, in node_is_subclass
    if inf.qname() in subclass_names:
AttributeError: 'AssignAttr' object has no attribute 'qname'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/circleci/project/.venv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/run.py", line 344, in __init__
    linter.check(args)
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 878, in check
    files_or_modules,
  File "/home/circleci/project/.venv/lib/python3.7/site-packages/pylint/lint/check_parallel.py", line 102, in check_parallel
    _worker_check_single_file, files
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
AttributeError: 'AssignAttr' object has no attribute 'qname'

Exited with code exit status 1
certi-github commented 4 years ago

Here I'm getting the same issue, but as above friend happening sometimes... There is the package versions:

prospector 1.1.7
pylint 2.3.1
astroid 2.2.5
Python 3.6.5
# prospector -X 
Traceback (most recent call last):
  File "/usr/local/bin/prospector", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/prospector/run.py", line 173, in main
    prospector.execute()
  File "/usr/local/lib/python3.6/site-packages/prospector/run.py", line 66, in execute
    messages += tool.run(found_files)
  File "/usr/local/lib/python3.6/site-packages/prospector/tools/pylint/__init__.py", line 267, in run
    self._linter.check(self._args)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1004, in check
    self._do_check(files_or_modules)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1165, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1252, in check_astroid_module
    walker.walk(ast_node)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 55, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 146, in do_suppress
    chain()
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 54, in chain
    old_method(node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 55, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 146, in do_suppress
    chain()
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 54, in chain
    old_method(node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 55, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 146, in do_suppress
    chain()
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 54, in chain
    old_method(node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 55, in augment_func
    augmentation(chain, node)
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 146, in do_suppress
    chain()
  File "/usr/local/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 54, in chain
    old_method(node)
  File "/usr/local/lib/python3.6/site-packages/pylint/checkers/classes.py", line 755, in visit_classdef
    self._check_bases_classes(node)
  File "/usr/local/lib/python3.6/site-packages/pylint/checkers/classes.py", line 1541, in _check_bases_classes
    unimplemented_abstract_methods(node, is_abstract).items(),
  File "/usr/local/lib/python3.6/site-packages/pylint/checkers/utils.py", line 803, in unimplemented_abstract_methods
    inferred = safe_infer(obj)
  File "/usr/local/lib/python3.6/site-packages/pylint/checkers/utils.py", line 1084, in safe_infer
    value = next(inferit)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/bases.py", line 133, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python3.6/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/usr/local/lib/python3.6/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/inference.py", line 221, in infer_call
    for callee in self.func.infer(context):
  File "/usr/local/lib/python3.6/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/usr/local/lib/python3.6/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/bases.py", line 133, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python3.6/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/usr/local/lib/python3.6/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 92, in wrapped
    generator = _func(node, context, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/astroid/inference.py", line 267, in infer_import_from
    module = self.do_import_module()
  File "/usr/local/lib/python3.6/site-packages/astroid/mixins.py", line 100, in do_import_module
    modname, level=level, relative_only=level and level >= 1
  File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 629, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/usr/local/lib/python3.6/site-packages/astroid/manager.py", line 177, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/usr/local/lib/python3.6/site-packages/astroid/manager.py", line 95, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/usr/local/lib/python3.6/site-packages/astroid/builder.py", line 136, in file_build
    return self._post_build(module, encoding)
  File "/usr/local/lib/python3.6/site-packages/astroid/builder.py", line 156, in _post_build
    self.delayed_assattr(delayed)
  File "/usr/local/lib/python3.6/site-packages/astroid/builder.py", line 223, in delayed_assattr
    for inferred in node.expr.infer():
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/bases.py", line 133, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/usr/local/lib/python3.6/site-packages/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/usr/local/lib/python3.6/site-packages/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/usr/local/lib/python3.6/site-packages/astroid/decorators.py", line 92, in wrapped
    generator = _func(node, context, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/astroid/inference.py", line 840, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "/usr/local/lib/python3.6/site-packages/astroid/protocols.py", line 324, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == "metaclass"
  File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 1785, in _class_type
    if _is_metaclass(klass):
  File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 1771, in _is_metaclass
    if _is_metaclass(baseobj, seen):
  File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 1755, in _is_metaclass
    baseobj_name = baseobj.qname()
AttributeError: 'AssignAttr' object has no attribute 'qname'
dgrant commented 4 years ago

I'm getting this error too.

astroid==2.4.1 prospector[with_everything]==1.3.0 pylint-celery==0.3 pylint-django==2.0.15 pylint-flask==0.6 pylint-plugin-utils==0.6 pylint==2.5.2

gmakridakis commented 3 years ago

Hello all, I am getting the same error with the following configuration

pylint 2.5.2
astroid 2.5
Python 3.8.9 (default, Apr 19 2021, 16:25:00) 
[GCC 9.3.0]

pylint-django = "2.4.2" but also appears with v2.4.4 as well.

In my case the error is happening consistently, when pylint checks a certain file.

If patching pylint_django/utils.py with @chdsbd 's commit ( https://github.com/AdmitHub/pylint-django/commit/57159e501d73b0e9a3ee0bbe45d92fb22aabea0d ) the issue is resolved, however I can see that this certain change is not merged to v2.4.4

niall-byrne commented 2 years ago

I am seeing this issue as well. Downgrading Pylint was my workaround. Is there any chance of re-examining the decision not to merge this change set?

carlio commented 2 years ago

@niall-byrne can you post your pip freeze (at least the bits containing pylint-django, pylint and astroid?) There were some recent fixes for newer versions of astroid but pylint and astroid change a lot so knowing the combination of the 3 versions is a good starting place to dig into this.

carlio commented 2 years ago

Bleh, each stacktrace contains something like

File "/usr/local/lib/python3.6/site-packages/astroid/scoped_nodes.py", line 1755, in _is_metaclass
    baseobj_name = baseobj.qname()
AttributeError: 'AssignAttr' object has no attribute 'qname'

See https://github.com/PyCQA/pylint-django/issues/343 which is related to that scoped_nodes.py change in astroid.

It might be the case that with newer versions of pylint/astroid your issue might go away.

niall-byrne commented 2 years ago

@carlio No problem. I actually downgraded a lot of packages troubleshooting this... seems I should have just tried an older version of Astroid? I downgraded one version, but I see an older version referenced in the thread you mentioned. Seems this is actually the correct action item.

(Please note the problem is actually intermittent! It shows up in some CI runs, but not in others- so it may be that I think it's resolved but it will rear it's head again... worst kind of issue unfortunately.)

The repo is open source: https://github.com/grocerypanic/grocerypanic-backend You can view the CI logs yourself to see the stack trace.