mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +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
|
self.version = version
|
||||||
#: The prelimary argument parser for handling options required for
|
#: The prelimary argument parser for handling options required for
|
||||||
#: obtaining and parsing the configuration file.
|
#: obtaining and parsing the configuration file.
|
||||||
self.prelim_arg_parser = argparse.ArgumentParser(add_help=False)
|
self.prelim_arg_parser = options.stage1_arg_parser()
|
||||||
options.register_preliminary_options(self.prelim_arg_parser)
|
|
||||||
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
||||||
#: to parse and handle the options and arguments passed by the user
|
#: to parse and handle the options and arguments passed by the user
|
||||||
self.option_manager = manager.OptionManager(
|
self.option_manager = manager.OptionManager(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from flake8 import defaults
|
||||||
from flake8.options.manager import OptionManager
|
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.
|
"""Register the preliminary options on our OptionManager.
|
||||||
|
|
||||||
The preliminary options include:
|
The preliminary options include:
|
||||||
|
|
@ -16,9 +16,9 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
||||||
- ``--config``
|
- ``--config``
|
||||||
- ``--isolated``
|
- ``--isolated``
|
||||||
"""
|
"""
|
||||||
add_argument = parser.add_argument
|
parser = argparse.ArgumentParser(add_help=False)
|
||||||
|
|
||||||
add_argument(
|
parser.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
default=0,
|
default=0,
|
||||||
|
|
@ -28,13 +28,13 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
||||||
"time it is repeated.",
|
"time it is repeated.",
|
||||||
)
|
)
|
||||||
|
|
||||||
add_argument(
|
parser.add_argument(
|
||||||
"--output-file", default=None, help="Redirect report to a file."
|
"--output-file", default=None, help="Redirect report to a file."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Config file options
|
# Config file options
|
||||||
|
|
||||||
add_argument(
|
parser.add_argument(
|
||||||
"--append-config",
|
"--append-config",
|
||||||
action="append",
|
action="append",
|
||||||
default=[],
|
default=[],
|
||||||
|
|
@ -44,7 +44,7 @@ def register_preliminary_options(parser: argparse.ArgumentParser) -> None:
|
||||||
"provide the same option.",
|
"provide the same option.",
|
||||||
)
|
)
|
||||||
|
|
||||||
add_argument(
|
parser.add_argument(
|
||||||
"--config",
|
"--config",
|
||||||
default=None,
|
default=None,
|
||||||
help="Path to the config file that will be the authoritative config "
|
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.",
|
"configuration files.",
|
||||||
)
|
)
|
||||||
|
|
||||||
add_argument(
|
parser.add_argument(
|
||||||
"--isolated",
|
"--isolated",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Ignore all configuration files.",
|
help="Ignore all configuration files.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class JobsArgument:
|
class JobsArgument:
|
||||||
"""Type callback for the --jobs argument."""
|
"""Type callback for the --jobs argument."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue