mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 12:16:53 +00:00
application: Remove preliminary argument parsing state
The preliminary options and arguments returned from `.parse_preliminary_options_and_args()` are now all threaded through to the appropriate methods during initialization.
This commit is contained in:
parent
95a88e3fcd
commit
b54164f916
3 changed files with 4 additions and 17 deletions
|
|
@ -51,11 +51,6 @@ class Application(object):
|
|||
prog="flake8", version=flake8.__version__
|
||||
)
|
||||
options.register_default_options(self.option_manager)
|
||||
#: The preliminary options parsed from CLI before plugins are loaded,
|
||||
#: into a :class:`argparse.Namespace` instance
|
||||
self.prelim_opts = None # type: argparse.Namespace
|
||||
#: The preliminary arguments parsed from CLI before plugins are loaded
|
||||
self.prelim_args = None # type: List[str]
|
||||
#: The instance of :class:`flake8.options.config.ConfigFileFinder`
|
||||
self.config_finder = None # type: config.ConfigFileFinder
|
||||
|
||||
|
|
@ -108,8 +103,6 @@ class Application(object):
|
|||
options; we ignore those for now, they'll be parsed later when we do
|
||||
real option parsing.
|
||||
|
||||
Sets self.prelim_opts and self.prelim_args.
|
||||
|
||||
:param list argv:
|
||||
Command-line arguments passed in directly.
|
||||
:returns:
|
||||
|
|
@ -142,7 +135,6 @@ class Application(object):
|
|||
opts, args = self.option_manager.parse_known_args(args)
|
||||
# parse_known_args includes unknown options as args
|
||||
args = [a for a in args if not a.startswith("-")]
|
||||
self.prelim_opts, self.prelim_args = opts, args
|
||||
return opts, args
|
||||
|
||||
def exit(self):
|
||||
|
|
|
|||
|
|
@ -95,12 +95,9 @@ def test_prelim_opts_args(application):
|
|||
opts, args = application.parse_preliminary_options_and_args(
|
||||
['flake8', '--foo', '--verbose', 'src', 'setup.py', '--statistics'])
|
||||
|
||||
assert application.prelim_opts.statistics
|
||||
assert application.prelim_opts.verbose
|
||||
assert application.prelim_args == ['src', 'setup.py']
|
||||
assert opts.statistics is application.prelim_opts.statistics
|
||||
assert opts.verbose is application.prelim_opts.verbose
|
||||
assert args is application.prelim_args
|
||||
assert opts.statistics
|
||||
assert opts.verbose
|
||||
assert args == ['src', 'setup.py']
|
||||
|
||||
|
||||
def test_prelim_opts_handles_empty(application):
|
||||
|
|
@ -109,5 +106,4 @@ def test_prelim_opts_handles_empty(application):
|
|||
with mock.patch.object(sys, 'argv', irrelevant_args):
|
||||
opts, args = application.parse_preliminary_options_and_args([])
|
||||
|
||||
assert application.prelim_args == []
|
||||
assert args is application.prelim_args
|
||||
assert args == []
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ def test_get_style_guide():
|
|||
verbose=0,
|
||||
)
|
||||
mockedapp = mock.Mock()
|
||||
mockedapp.prelim_opts = prelim_opts
|
||||
mockedapp.parse_preliminary_options_and_args.return_value = (
|
||||
prelim_opts,
|
||||
[],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue