summaryrefslogtreecommitdiff
path: root/pylint/config/arguments_manager.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-06-04 13:49:52 +0200
committerGitHub <noreply@github.com>2022-06-04 13:49:52 +0200
commite49868c2bda9708c92a35474262ddfe14af0fdc9 (patch)
treeadd690ede408dd75bb682a64a993e1d33d387378 /pylint/config/arguments_manager.py
parent8ab9ab5c73f781871e320a65f73c778fe6b2a8eb (diff)
downloadpylint-git-e49868c2bda9708c92a35474262ddfe14af0fdc9.tar.gz
Store namespaces respective to directories (#6789)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/config/arguments_manager.py')
-rw-r--r--pylint/config/arguments_manager.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/pylint/config/arguments_manager.py b/pylint/config/arguments_manager.py
index 301769e77..eda1a583d 100644
--- a/pylint/config/arguments_manager.py
+++ b/pylint/config/arguments_manager.py
@@ -42,7 +42,7 @@ from pylint.config.option_parser import OptionParser
from pylint.config.options_provider_mixin import OptionsProviderMixIn
from pylint.config.utils import _convert_option_to_argument, _parse_rich_type_value
from pylint.constants import MAIN_CHECKER_NAME
-from pylint.typing import OptionDict
+from pylint.typing import DirectoryNamespaceDict, OptionDict
if sys.version_info >= (3, 11):
import tomllib
@@ -66,6 +66,14 @@ class _ArgumentsManager:
self._config = argparse.Namespace()
"""Namespace for all options."""
+ self._base_config = self._config
+ """Fall back Namespace object created during initialization.
+
+ This is necessary for the per-directory configuration support. Whenever we
+ fail to match a file with a directory we fall back to the Namespace object
+ created during initialization.
+ """
+
self._arg_parser = argparse.ArgumentParser(
prog=prog,
usage=usage or "%(prog)s [options]",
@@ -82,6 +90,9 @@ class _ArgumentsManager:
self._option_dicts: dict[str, OptionDict] = {}
"""All option dictionaries that have been registered."""
+ self._directory_namespaces: DirectoryNamespaceDict = {}
+ """Mapping of directories and their respective namespace objects."""
+
# TODO: 3.0: Remove deprecated attributes introduced to keep API
# parity with optparse. Until '_maxlevel'
with warnings.catch_warnings():