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:
Eric N. Vander Weele 2019-10-25 15:01:30 -04:00
parent a90200353e
commit 7f46990f4b
2 changed files with 4 additions and 3 deletions

View file

@ -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']