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

Issue using commandline flag with pylint #385

Open
slorg1 opened this issue Dec 5, 2022 · 0 comments
Open

Issue using commandline flag with pylint #385

slorg1 opened this issue Dec 5, 2022 · 0 comments

Comments

@slorg1
Copy link

slorg1 commented Dec 5, 2022

I get a crash now when using the commandline flags.

Fix #385

The issue is that creating the Settings objects already configures the settings.

See the symptom:

$ pylint --load-plugins=pylint_django --enable=W0611 --disable=bad-continuation,invalid-name,no-self-argument,E0211,C0116,C0115,C0114 --max-line-length=110 --django-settings-module=heypluto.settings.local **/*.py
************* Module Command line
Command line:1:0: R0022: Useless option value for '--disable', 'bad-continuation' was removed from pylint, see https://github.com/PyCQA/pylint/pull/3571. (useless-option-value)
Traceback (most recent call last):
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint_django/checkers/foreign_key_strings.py", line 92, in open
    django.setup()
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/django/conf/__init__.py", line 63, 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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dev/.virtualenvs/pluto-chat/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint/__init__.py", line 25, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint/lint/run.py", line 207, in __init__
    linter.check(args)
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 646, in check
    self._check_files(
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 681, in _check_files
    with self._astroid_module_checker() as check_astroid_module:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 859, in _astroid_module_checker
    checker.open()
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/pylint_django/checkers/foreign_key_strings.py", line 120, in open
    settings.configure(Settings(self.config.django_settings_module))
  File "/home/dev/.virtualenvs/pluto-chat/lib/python3.8/site-packages/django/conf/__init__.py", line 118, in configure
    raise RuntimeError('Settings already configured.')
RuntimeError: Settings already configured.

Pylint version:

$ pylint --version
pylint 2.14.5
astroid 2.11.7
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0]

Relevant pip freeze:

Django==3.2.16
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

Successfully merging a pull request may close this issue.

1 participant