mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
use return value of parse_args directly
This commit is contained in:
parent
d582affb2c
commit
8d3afe40e1
5 changed files with 21 additions and 26 deletions
|
|
@ -80,9 +80,6 @@ class Application:
|
|||
#: The user-supplied options parsed into an instance of
|
||||
#: :class:`argparse.Namespace`
|
||||
self.options: Optional[argparse.Namespace] = None
|
||||
#: The left over arguments that were not parsed by
|
||||
#: :attr:`option_manager`
|
||||
self.args: Optional[List[str]] = None
|
||||
#: The number of errors, warnings, and other messages after running
|
||||
#: flake8 and taking into account ignored errors and lines.
|
||||
self.result_count = 0
|
||||
|
|
@ -183,7 +180,7 @@ class Application:
|
|||
:param list argv:
|
||||
Command-line arguments passed in directly.
|
||||
"""
|
||||
self.options, self.args = aggregator.aggregate_options(
|
||||
self.options = aggregator.aggregate_options(
|
||||
self.option_manager,
|
||||
config_finder,
|
||||
argv,
|
||||
|
|
@ -201,11 +198,11 @@ class Application:
|
|||
|
||||
assert self.check_plugins is not None
|
||||
self.check_plugins.provide_options(
|
||||
self.option_manager, self.options, self.args
|
||||
self.option_manager, self.options, self.options.filenames
|
||||
)
|
||||
assert self.formatting_plugins is not None
|
||||
self.formatting_plugins.provide_options(
|
||||
self.option_manager, self.options, self.args
|
||||
self.option_manager, self.options, self.options.filenames
|
||||
)
|
||||
|
||||
def formatter_for(self, formatter_plugin_name):
|
||||
|
|
@ -251,9 +248,10 @@ class Application:
|
|||
|
||||
def make_file_checker_manager(self) -> None:
|
||||
"""Initialize our FileChecker Manager."""
|
||||
assert self.options is not None
|
||||
self.file_checker_manager = checker.Manager(
|
||||
style_guide=self.guide,
|
||||
arguments=self.args,
|
||||
arguments=self.options.filenames,
|
||||
checker_plugins=self.check_plugins,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ applies the user-specified command-line configuration on top of it.
|
|||
import argparse
|
||||
import logging
|
||||
from typing import List
|
||||
from typing import Tuple
|
||||
|
||||
from flake8.options import config
|
||||
from flake8.options.manager import OptionManager
|
||||
|
|
@ -18,7 +17,7 @@ def aggregate_options(
|
|||
manager: OptionManager,
|
||||
config_finder: config.ConfigFileFinder,
|
||||
argv: List[str],
|
||||
) -> Tuple[argparse.Namespace, List[str]]:
|
||||
) -> argparse.Namespace:
|
||||
"""Aggregate and merge CLI and config file options.
|
||||
|
||||
:param flake8.options.manager.OptionManager manager:
|
||||
|
|
@ -35,7 +34,7 @@ def aggregate_options(
|
|||
tuple(argparse.Namespace, list)
|
||||
"""
|
||||
# Get defaults from the option parser
|
||||
default_values, _ = manager.parse_args([])
|
||||
default_values = manager.parse_args([])
|
||||
|
||||
# Make our new configuration file mergerator
|
||||
config_parser = config.ConfigParser(
|
||||
|
|
|
|||
|
|
@ -459,15 +459,13 @@ class OptionManager:
|
|||
self,
|
||||
args: Optional[List[str]] = None,
|
||||
values: Optional[argparse.Namespace] = None,
|
||||
) -> Tuple[argparse.Namespace, List[str]]:
|
||||
) -> argparse.Namespace:
|
||||
"""Proxy to calling the OptionParser's parse_args method."""
|
||||
self.generate_epilog()
|
||||
self.update_version_string()
|
||||
if values:
|
||||
self.parser.set_defaults(**vars(values))
|
||||
parsed_args = self.parser.parse_args(args)
|
||||
# TODO: refactor callers to not need this
|
||||
return parsed_args, parsed_args.filenames
|
||||
return self.parser.parse_args(args)
|
||||
|
||||
def parse_known_args(
|
||||
self, args: Optional[List[str]] = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue