mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-01 19:36:54 +00:00
Set configuration file-provided values via ArgumentParser.set_defaults()
When calling `ArgumentParser.parse_args()` with the `namespace` argument, command-line options are just added to the namespace without going through any of the argument parsing and type conversion logic (e.g., the `type` keyword argument of `ArgumentParser.add_argument()`). In other words, it is assumed that a namespace is well-formed from a previous invocation of `ArgumentParser.parse_args()`. The `values` parameter is intended to be values already-provided from configuration files. To take advantage of the logic defined by `ArgumentParser.add_argument()`, utilize `ArgumentParser.set_defaults()` instead.
This commit is contained in:
parent
b231c10016
commit
aadd09dd8b
2 changed files with 11 additions and 1 deletions
|
|
@ -437,7 +437,9 @@ class OptionManager(object):
|
|||
assert isinstance( # nosec (for bandit)
|
||||
self.parser, argparse.ArgumentParser
|
||||
), self.parser
|
||||
parsed_args = self.parser.parse_args(args, values)
|
||||
if values:
|
||||
self.parser.set_defaults(**vars(values))
|
||||
parsed_args = self.parser.parse_args(args)
|
||||
# TODO: refactor callers to not need this
|
||||
return parsed_args, parsed_args.filenames
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue