Open
Description
According to django's docs, settings should be imported using from django.conf import settings
and not your own settings file; see https://docs.djangoproject.com/en/5.1/topics/settings/#using-settings-in-python-code
I recently ran into a bug in our dev environment where a setting gave an ImportError
using from myapp.mymodule import MY_SETTING
, apparently because that setting was defined using environment variables (I'm guessing there may be some lazy loading behavior here that is bypassed by importing the setting directly).
Since pylint-django knows about the application's settings module via DJANGO_SETTINGS_MODULE
, would it be possible to flag the incorrect style of import by looking for that module in import statements?
Metadata
Metadata
Assignees
Labels
No labels