diff options
| author | Eric N. Vander Weele <ericvw@gmail.com> | 2020-05-18 16:30:05 -0400 |
|---|---|---|
| committer | Eric N. Vander Weele <ericvw@gmail.com> | 2020-05-18 17:22:34 -0400 |
| commit | 8be5a7294bcdc40248e483b8a1ca734471179eda (patch) | |
| tree | 1fd19dcd2e1629d7b7e31e07f8a8d82c37e2824d /src/flake8/options | |
| parent | c8494e7ac0d017d032edc0a402c569b2fddb8a7f (diff) | |
| download | flake8-8be5a7294bcdc40248e483b8a1ca734471179eda.tar.gz | |
config: Normalize paths in config relative to provided parent directory
This sets things up to support normalizing paths relative to parent
directories specified by callers who have more context for determining
what paths should be relative to.
Diffstat (limited to 'src/flake8/options')
| -rw-r--r-- | src/flake8/options/config.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index 5884873..c258fec 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -184,9 +184,12 @@ class MergedConfigParser(object): #: Our instance of our :class:`~ConfigFileFinder` self.config_finder = config_finder - def _normalize_value(self, option, value): + def _normalize_value(self, option, value, parent=None): + if parent is None: + parent = self.config_finder.local_directory + final_value = option.normalize( - value, self.config_finder.local_directory + value, parent ) LOG.debug( '%r has been normalized to %r for option "%s"', @@ -196,7 +199,7 @@ class MergedConfigParser(object): ) return final_value - def _parse_config(self, config_parser): + def _parse_config(self, config_parser, parent=None): config_dict = {} for option_name in config_parser.options(self.program_name): if option_name not in self.config_options: @@ -216,7 +219,7 @@ class MergedConfigParser(object): value = method(self.program_name, option_name) LOG.debug('Option "%s" returned value: %r', option_name, value) - final_value = self._normalize_value(option, value) + final_value = self._normalize_value(option, value, parent) config_dict[option.config_name] = final_value return config_dict |
