mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-09 14:24:17 +00:00
Add typing to OptionManager.parse_args()
Note that the `assert` is necessary to "cast" `self.parser` since it is specified as a `Union`.
This commit is contained in:
parent
eee53d9440
commit
ec8fcfc8f8
1 changed files with 11 additions and 3 deletions
|
|
@ -425,13 +425,21 @@ class OptionManager(object):
|
||||||
plugin_version_format
|
plugin_version_format
|
||||||
)
|
)
|
||||||
|
|
||||||
def parse_args(self, args=None, values=None):
|
def parse_args(
|
||||||
|
self,
|
||||||
|
args=None, # type: Optional[List[str]]
|
||||||
|
values=None, # type: Optional[argparse.Namespace]
|
||||||
|
):
|
||||||
|
# type: (...) -> Tuple[argparse.Namespace, List[str]]
|
||||||
"""Proxy to calling the OptionParser's parse_args method."""
|
"""Proxy to calling the OptionParser's parse_args method."""
|
||||||
self.generate_epilog()
|
self.generate_epilog()
|
||||||
self.update_version_string()
|
self.update_version_string()
|
||||||
args = self.parser.parse_args(args, values)
|
assert isinstance( # nosec (for bandit)
|
||||||
|
self.parser, argparse.ArgumentParser
|
||||||
|
), self.parser
|
||||||
|
parsed_args = self.parser.parse_args(args, values)
|
||||||
# TODO: refactor callers to not need this
|
# TODO: refactor callers to not need this
|
||||||
return args, args.filenames
|
return parsed_args, parsed_args.filenames
|
||||||
|
|
||||||
def parse_known_args(self, args=None):
|
def parse_known_args(self, args=None):
|
||||||
# type: (Optional[List[str]]) -> Tuple[argparse.Namespace, List[str]]
|
# type: (Optional[List[str]]) -> Tuple[argparse.Namespace, List[str]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue