summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric N. Vander Weele <ericvw@gmail.com>2019-11-03 01:11:43 +0000
committerAnthony Sottile <asottile@umich.edu>2019-11-03 01:11:43 +0000
commit6c117cedd7f5294606a368a6f883f19d3f040670 (patch)
treea886b1e14e6cf4e78bf2afaf846880b5ab3c7967 /src
parentff871fe656578248aa2add60a3873753f9d5e6bb (diff)
downloadflake8-6c117cedd7f5294606a368a6f883f19d3f040670.tar.gz
aggregator: Simplify 'aggregate_options' function definition
The `values` parameter is safe to remove since it is not provided as an argument by any callers and the remaining arguments are guaranteed to always be provided by all callers.
Diffstat (limited to 'src')
-rw-r--r--src/flake8/options/aggregator.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/flake8/options/aggregator.py b/src/flake8/options/aggregator.py
index 1b9c60c..719160a 100644
--- a/src/flake8/options/aggregator.py
+++ b/src/flake8/options/aggregator.py
@@ -3,26 +3,30 @@
This holds the logic that uses the collected and merged config files and
applies the user-specified command-line configuration on top of it.
"""
+import argparse
import logging
+from typing import List, Tuple
from flake8.options import config
+from flake8.options.manager import OptionManager
LOG = logging.getLogger(__name__)
-def aggregate_options(manager, config_finder, arglist=None, values=None):
+def aggregate_options(
+ manager, # type: OptionManager
+ config_finder, # type: config.ConfigFileFinder
+ argv, # type: List[str]
+): # type: (...) -> Tuple[argparse.Namespace, List[str]]
"""Aggregate and merge CLI and config file options.
:param flake8.options.manager.OptionManager manager:
The instance of the OptionManager that we're presently using.
:param flake8.options.config.ConfigFileFinder config_finder:
The config file finder to use.
- :param list arglist:
- The list of arguments to pass to ``manager.parse_args``. In most cases
- this will be None so ``parse_args`` uses ``sys.argv``. This is mostly
- available to make testing easier.
- :param argparse.Namespace values:
- Previously parsed set of parsed options.
+ :param list argv:
+ The list of remaining command-line argumentsthat were unknown during
+ preliminary option parsing to pass to ``manager.parse_args``.
:returns:
Tuple of the parsed options and extra arguments returned by
``manager.parse_args``.
@@ -30,10 +34,10 @@ def aggregate_options(manager, config_finder, arglist=None, values=None):
tuple(argparse.Namespace, list)
"""
# Get defaults from the option parser
- default_values, _ = manager.parse_args([], values=values)
+ default_values, _ = manager.parse_args([])
# Get original CLI values so we can find additional config file paths and
# see if --config was specified.
- original_values, _ = manager.parse_args(arglist)
+ original_values, _ = manager.parse_args(argv)
# Make our new configuration file mergerator
config_parser = config.MergedConfigParser(
@@ -79,4 +83,4 @@ def aggregate_options(manager, config_finder, arglist=None, values=None):
setattr(default_values, dest_name, value)
# Finally parse the command-line options
- return manager.parse_args(arglist, default_values)
+ return manager.parse_args(argv, default_values)