mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
return an argparser instead of side-effects
This commit is contained in:
parent
1587936e2a
commit
3fa044ca4b
2 changed files with 10 additions and 9 deletions
|
|
@ -55,8 +55,7 @@ class Application:
|
|||
self.version = version
|
||||
#: The prelimary argument parser for handling options required for
|
||||
#: obtaining and parsing the configuration file.
|
||||
self.prelim_arg_parser = argparse.ArgumentParser(add_help=False)
|
||||
options.register_preliminary_options(self.prelim_arg_parser)
|
||||
self.prelim_arg_parser = options.stage1_arg_parser()
|
||||
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
||||
#: to parse and handle the options and arguments passed by the user
|
||||
self.option_manager = manager.OptionManager(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from flake8 import defaults
|
|||
from flake8.options.manager import OptionManager
|
||||
|
||||
|
||||
def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
||||
def stage1_arg_parser() -> argparse.ArgumentParser:
|
||||
"""Register the preliminary options on our OptionManager.
|
||||
|
||||
The preliminary options include:
|
||||
|
|
@ -16,9 +16,9 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
|||
- ``--config``
|
||||
- ``--isolated``
|
||||
"""
|
||||
add_argument = parser.add_argument
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
|
||||
add_argument(
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
default=0,
|
||||
|
|
@ -28,13 +28,13 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
|||
"time it is repeated.",
|
||||
)
|
||||
|
||||
add_argument(
|
||||
parser.add_argument(
|
||||
"--output-file", default=None, help="Redirect report to a file."
|
||||
)
|
||||
|
||||
# Config file options
|
||||
|
||||
add_argument(
|
||||
parser.add_argument(
|
||||
"--append-config",
|
||||
action="append",
|
||||
default=[],
|
||||
|
|
@ -44,7 +44,7 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
|||
"provide the same option.",
|
||||
)
|
||||
|
||||
add_argument(
|
||||
parser.add_argument(
|
||||
"--config",
|
||||
default=None,
|
||||
help="Path to the config file that will be the authoritative config "
|
||||
|
|
@ -52,13 +52,15 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
|||
"configuration files.",
|
||||
)
|
||||
|
||||
add_argument(
|
||||
parser.add_argument(
|
||||
"--isolated",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Ignore all configuration files.",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
class JobsArgument:
|
||||
"""Type callback for the --jobs argument."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue