summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Stapleton Cordasco <graffatcolmingov@gmail.com>2021-10-10 19:21:35 -0500
committerGitHub <noreply@github.com>2021-10-10 19:21:35 -0500
commit283f0c81241673221d9628beb11e2d7356826f00 (patch)
tree14c10b9f867c0f955a2722bee6e24b71690ae27d /src
parent0b1c790443a9777c5d945f963e22571698fadf8c (diff)
parent807904aebc20814ac595b0004ab526fffb5ef681 (diff)
downloadflake8-283f0c81241673221d9628beb11e2d7356826f00.tar.gz
Merge pull request #1404 from PyCQA/drop-xdg-config
Drop support for Home and XDG config files
Diffstat (limited to 'src')
-rw-r--r--src/flake8/options/aggregator.py2
-rw-r--r--src/flake8/options/config.py64
2 files changed, 6 insertions, 60 deletions
diff --git a/src/flake8/options/aggregator.py b/src/flake8/options/aggregator.py
index 40848a2..73a0f36 100644
--- a/src/flake8/options/aggregator.py
+++ b/src/flake8/options/aggregator.py
@@ -38,7 +38,7 @@ def aggregate_options(
default_values, _ = manager.parse_args([])
# Make our new configuration file mergerator
- config_parser = config.MergedConfigParser(
+ config_parser = config.ConfigParser(
option_manager=manager, config_finder=config_finder
)
diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py
index e920e58..fc3b205 100644
--- a/src/flake8/options/config.py
+++ b/src/flake8/options/config.py
@@ -11,7 +11,7 @@ from flake8 import utils
LOG = logging.getLogger(__name__)
-__all__ = ("ConfigFileFinder", "MergedConfigParser")
+__all__ = ("ConfigFileFinder", "ConfigParser")
class ConfigFileFinder:
@@ -48,7 +48,6 @@ class ConfigFileFinder:
# User configuration file.
self.program_name = program_name
- self.user_config_file = self._user_config_file(program_name)
# List of filenames to find in the local/project directory
self.project_filenames = ("setup.cfg", "tox.ini", f".{program_name}")
@@ -56,19 +55,6 @@ class ConfigFileFinder:
self.local_directory = os.path.abspath(os.curdir)
@staticmethod
- def _user_config_file(program_name: str) -> str:
- if utils.is_windows():
- home_dir = os.path.expanduser("~")
- config_file_basename = f".{program_name}"
- else:
- home_dir = os.environ.get(
- "XDG_CONFIG_HOME", os.path.expanduser("~/.config")
- )
- config_file_basename = program_name
-
- return os.path.join(home_dir, config_file_basename)
-
- @staticmethod
def _read_config(
*files: str,
) -> Tuple[configparser.RawConfigParser, List[str]]:
@@ -146,15 +132,8 @@ class ConfigFileFinder:
"""Parse all local config files into one config object."""
return self.local_configs_with_files()[0]
- def user_config(self):
- """Parse the user config file into a config object."""
- config, found_files = self._read_config(self.user_config_file)
- if found_files:
- LOG.debug("Found user configuration files: %s", found_files)
- return config
-
-class MergedConfigParser:
+class ConfigParser:
"""Encapsulate merging different types of configuration files.
This parses out the options registered that were specified in the
@@ -167,7 +146,7 @@ class MergedConfigParser:
GETBOOL_ACTIONS = {"store_true", "store_false"}
def __init__(self, option_manager, config_finder):
- """Initialize the MergedConfigParser instance.
+ """Initialize the ConfigParser instance.
:param flake8.options.manager.OptionManager option_manager:
Initialized OptionManager.
@@ -239,19 +218,6 @@ class MergedConfigParser:
LOG.debug("Parsing local configuration files.")
return self._parse_config(config)
- def parse_user_config(self):
- """Parse and return the user configuration files."""
- config = self.config_finder.user_config()
- if not self.is_configured_by(config):
- LOG.debug(
- "User configuration files have no %s section",
- self.program_name,
- )
- return {}
-
- LOG.debug("Parsing user configuration files.")
- return self._parse_config(config)
-
def parse_cli_config(self, config_path):
"""Parse and return the file specified by --config."""
config = self.config_finder.cli_config(config_path)
@@ -265,28 +231,8 @@ class MergedConfigParser:
LOG.debug("Parsing CLI configuration files.")
return self._parse_config(config, os.path.dirname(config_path))
- def merge_user_and_local_config(self):
- """Merge the parsed user and local configuration files.
-
- :returns:
- Dictionary of the parsed and merged configuration options.
- :rtype:
- dict
- """
- user_config = self.parse_user_config()
- config = self.parse_local_config()
-
- for option, value in user_config.items():
- config.setdefault(option, value)
-
- return config
-
def parse(self):
- """Parse and return the local and user config files.
-
- First this copies over the parsed local configuration and then
- iterates over the options in the user configuration and sets them if
- they were not set by the local configuration file.
+ """Parse and return the local config files.
:returns:
Dictionary of parsed configuration options
@@ -309,7 +255,7 @@ class MergedConfigParser:
)
return self.parse_cli_config(self.config_finder.config_file)
- return self.merge_user_and_local_config()
+ return self.parse_local_config()
def get_local_plugins(config_finder):