mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 22:04:17 +00:00
Merge branch 'type-parse-known-args' into 'master'
Add typing to `OptionManager.parse_known_args()` See merge request pycqa/flake8!348
This commit is contained in:
commit
822fab60f3
1 changed files with 8 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Generator, List, Optional, Set, Union
|
from typing import Any, Dict, Generator, List, Optional, Set, Tuple, Union
|
||||||
|
|
||||||
from flake8 import utils
|
from flake8 import utils
|
||||||
|
|
||||||
|
|
@ -434,6 +434,7 @@ class OptionManager(object):
|
||||||
return args, args.filenames
|
return args, 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]]
|
||||||
"""Parse only the known arguments from the argument values.
|
"""Parse only the known arguments from the argument values.
|
||||||
|
|
||||||
Replicate a little argparse behaviour while we're still on
|
Replicate a little argparse behaviour while we're still on
|
||||||
|
|
@ -441,8 +442,12 @@ class OptionManager(object):
|
||||||
"""
|
"""
|
||||||
self.generate_epilog()
|
self.generate_epilog()
|
||||||
self.update_version_string()
|
self.update_version_string()
|
||||||
args, rest = self.parser.parse_known_args(args)
|
# TODO: Re-evaluate `self.parser` swap happening in `group()` to
|
||||||
return args, rest
|
# avoid needing to assert to satify static type checking.
|
||||||
|
assert isinstance( # nosec (for bandit)
|
||||||
|
self.parser, argparse.ArgumentParser
|
||||||
|
), self.parser
|
||||||
|
return self.parser.parse_known_args(args)
|
||||||
|
|
||||||
def register_plugin(self, name, version, local=False):
|
def register_plugin(self, name, version, local=False):
|
||||||
"""Register a plugin relying on the OptionManager.
|
"""Register a plugin relying on the OptionManager.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue