mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 19:56:54 +00:00
application: Change to argparse.ArgumentParser for preliminary parsing
Now that preliminary options are registered with the preliminary parser on the `Application`, leverage that for parsing known options. This important change removes the `Application.option_manager` from being responsible for pre-configuration parsing and the workarounds needed in the `Application.parse_preliminary_options_and_args()` to account for the fact that `Application.option_manager` was aware of *all* options, not just the options necessary for pre-configuration loading. A following commit will address removing these workarounds.
This commit is contained in:
parent
a90200353e
commit
7f46990f4b
2 changed files with 4 additions and 3 deletions
|
|
@ -138,7 +138,7 @@ class Application(object):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
opts, args = self.option_manager.parse_known_args(args)
|
||||
opts, args = self.prelim_arg_parser.parse_known_args(args)
|
||||
# parse_known_args includes unknown options as args
|
||||
args = [a for a in args if not a.startswith("-")]
|
||||
return opts, args
|
||||
|
|
|
|||
|
|
@ -93,9 +93,10 @@ def test_returns_specified_plugin(application):
|
|||
def test_prelim_opts_args(application):
|
||||
"""Verify we get sensible prelim opts and args."""
|
||||
opts, args = application.parse_preliminary_options_and_args(
|
||||
['flake8', '--foo', '--verbose', 'src', 'setup.py', '--statistics'])
|
||||
['--foo', '--verbose', 'src', 'setup.py', '--statistics'])
|
||||
|
||||
assert opts.statistics
|
||||
assert not hasattr(opts, 'foo')
|
||||
assert not hasattr(opts, 'statistics')
|
||||
assert opts.verbose
|
||||
assert args == ['src', 'setup.py']
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue