Open sylvain1811 opened 3 years ago
For what it's worth, I'm having this happen too, but only if I use pylint's --django-settings-module. If I set DJANGO_SETTINGS_MODULE first, it goes away. And I looked at #306 and I'm pretty sure he was having the same issue.
# pylint --load-plugins pylint_django --django-settings-module=config.settings.base ticketing
Running insecure for localhost.
Traceback (most recent call last):
File "/Users/ash/.pyenv/versions/django/lib/python3.9/site-packages/pylint_django/checkers/foreign_key_strings.py", line 90, in open
django.setup()
File "/Users/ash/.pyenv/versions/django/lib/python3.9/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/ash/.pyenv/versions/django/lib/python3.9/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/Users/ash/.pyenv/versions/django/lib/python3.9/site-packages/django/conf/__init__.py", line 60, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
...
But...
# DJANGO_SETTINGS_MODULE=config.settings.base pylint --load-plugins pylint_django ticketing
************* Module ticketing
ticketing/__init__.py:4:19: R1728: Consider using a generator instead 'tuple(int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.'))' (consider-using-generator)
...
So it's not that my Django config is broken, it's not. The app runs fine. It's something specific with how init is handled with the cli option vs. the environment variable. Hope this helps you track it down...
Confirmed, downgrading to 2.3.0 fixed this for me as well.
Using the ENV variable instead of the parameter as @dragonpaw did; did not
Cheers @Routhinator , downgrading saved my sanity
I'm getting the following error when I run
pylint
on my project usingpylint-django==2.4.2
:I have a
.pylintrc
file loadingpylint-django
, and I think I correctly use--django-settings-module=myapp.settings
command line argument. I also tried to adddjango-settings-module=myapp.settings
in my.pylintrc
, still failed.I've read comments on #306, especially this one and I think it's an issue of
pylint-django
itself and not about configuration, so I create this issue.Workaround: downgrade to 2.3.0