Open aldokkani opened 5 years ago
This happens because of Django django.db.models.DecimalField
I'm seeing the same issue with pylint v2.3.1.
from wagtail.core.models import Page
class BlogIndexPage(Page):
content_panels = Page.content_panels # noqa
$ pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.7.3 (default, Apr 9 2019, 04:56:51)
[GCC 8.3.0]
$ pylint blog/models2.py
Traceback (most recent call last):
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/__init__.py", line 91, in _inference_tip_cached
return iter(_cache[func, node])
KeyError: (<function infer_key_classes at 0x7f37c6971378>, <Call l.245 at 0x7f37c5dbd550>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dani/repos/jobs_aggregator/venv/bin/pylint", line 11, in <module>
sys.exit(run_pylint())
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
Run(sys.argv[1:])
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/lint.py", line 1628, in __init__
linter.check(args)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/lint.py", line 943, in check
self._do_check(files_or_modules)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/lint.py", line 1075, in _do_check
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/lint.py", line 1158, in check_astroid_module
walker.walk(ast_node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/utils.py", line 1303, in walk
self.walk(child)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/utils.py", line 1300, in walk
cb(astroid)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
augmentation(chain, node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
chain()
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
old_method(node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
augmentation(chain, node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
chain()
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
old_method(node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
augmentation(chain, node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
chain()
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
old_method(node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
augmentation(chain, node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
chain()
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
old_method(node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/checkers/classes.py", line 729, in visit_classdef
self._check_bases_classes(node)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/checkers/classes.py", line 1444, in _check_bases_classes
unimplemented_abstract_methods(node, is_abstract).items(),
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/checkers/utils.py", line 782, in unimplemented_abstract_methods
infered = safe_infer(obj)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint/checkers/utils.py", line 1066, in safe_infer
value = next(inferit)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
yield next(generator)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
res = next(generator)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/bases.py", line 137, in _infer_stmts
for inferred in stmt.infer(context=context):
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/node_classes.py", line 348, in infer
return self._explicit_inference(self, context, **kwargs)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/__init__.py", line 93, in _inference_tip_cached
result = func(*args, **kwargs)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/pylint_django/transforms/foreignkey.py", line 96, in infer_key_classes
MANAGER.ast_from_module_name(module_name)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/manager.py", line 178, in ast_from_module_name
raise e
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/manager.py", line 129, in ast_from_module_name
found_spec = self.file_from_module_name(modname, context_file)
File "/home/dani/repos/jobs_aggregator/venv/lib/python3.7/site-packages/astroid/manager.py", line 222, in file_from_module_name
raise value
astroid.exceptions.AstroidImportError: Failed to import module contenttypes.models with error:
No module named contenttypes.models.
still experiencing this with a content type... error occurs when I add a init.py file
error
astroid.exceptions.AstroidImportError: Failed to import module <app>.models with error:
No module named <app>.models.
folder structure
project/
app/
__init__.py
models.py <- where it says offending content type error occurs
__init__.py <- when added, get error. deletion lints files normally
Just ran into a similar issue when using string literals in a Django ForeignKey:
product = models.ForeignKey(
"curriculum.Product",
)
Which caused prospector to raise the following error:
astroid.exceptions.AstroidImportError: Failed to import module curriculum.models with error:
No module named curriculum.models.
After reading your comment I found a __init__.py
file residing in my src
directory and the issue disappeared when I removed this file!
project/
src/
users/
curriculum
(...)
__init__.py
So, future perusers of this thread, delete your redundant __init__.py
files, it might solve the issue!
This happened out of a sudden, I didn't change anything.
Output:
Traceback:
requirements: