Skip to content

Failure to import settings?  #325

Open
@bschollnick

Description

@bschollnick

I am running into several issues...

But here's my structure:

├── pycache
├── django_jinja
│   ├── pycache
│   ├── builtins
│   ├── contrib
│   ├── management
│   └── views
├── frontend
│   ├── pycache
│   ├── management
│   └── testcode
├── numpy_git
│   ├── benchmarks
│   ├── branding
│   ├── changelog
│   ├── doc
│   ├── numpy
│   └── tools
├── quickbbs
│   ├── pycache
│   ├── middleware
│   └── migrations
├── static
│   ├── admin
│   ├── css
│   ├── debug_toolbar
│   ├── fonts
│   ├── grappelli
│   ├── javascript
│   ├── silk
│   └── thumbnails
└── templates
├── allauth
└── frontend

`
If I use the following, and my settings file does exist as quickbbs/settings.py

export DJANGO_SETTINGS_MODULE=quickbbs.settings
pylint --load-plugins pylint_django --django-settings-module=quickbbs.settings $1 $2 $3 $4

But it exceptions with an error indicating that pylint-django can't find the settings file?

(quickbbs) benjamin@Nerv quickbbs % djangolint.command frontend/ftypes.py
Traceback (most recent call last):
  File "/Users/benjamin/venvs/quickbbs/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint/lint/run.py", line 381, in __init__
    linter.check(args)
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 873, in check
    self._check_files(
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 905, in _check_files
    with self._astroid_module_checker() as check_astroid_module:
  File "/opt/homebrew/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1014, in _astroid_module_checker
    checker.open()
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/pylint_django/checkers/foreign_key_strings.py", line 90, in open
    django.setup()
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/opt/homebrew/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'quickbbs.settings'

I've tried it without the export, and just with the command line option, and I've tried it with the export and without the command line option, same effect.

The export solved the LOGGING error, so I believe that pylint is seeing the settings file, I just don't understand why pylint-django isn't.

Is there some strange syntax that I'm missing? pylint-django use to work fine a while back.... But I haven't touched this project with pylint-django in a quite a while.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions