diff --git a/doc/whatsnew/fragments/7938.bugfix b/doc/whatsnew/fragments/7938.bugfix new file mode 100644 index 0000000000..1cffb9d1f4 --- /dev/null +++ b/doc/whatsnew/fragments/7938.bugfix @@ -0,0 +1,3 @@ +Fixes a ``ModuleNotFound`` exception when running pylint on a Django project with the ``pylint_django`` plugin enabled. + +Closes #7938 diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 5a600eb5ba..e8923ad27f 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -690,8 +690,8 @@ def check(self, files_or_modules: Sequence[str] | str) -> None: data = None # The contextmanager also opens all checkers and sets up the PyLinter class - with self._astroid_module_checker() as check_astroid_module: - with fix_import_path(files_or_modules): + with fix_import_path(files_or_modules): + with self._astroid_module_checker() as check_astroid_module: # 4) Get the AST for each FileItem ast_per_fileitem = self._get_asts(fileitems, data)