Skip to content

Improve overloads of parse_args() -- it never returns None #2643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stdlib/2and3/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,18 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
argument_default: Optional[_Text] = ...,
conflict_handler: _Text = ...,
add_help: bool = ...) -> None: ...

# The type-ignores in these overloads should be temporary. See:
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
@overload
def parse_args(self, args: Optional[Sequence[_Text]] = ...) -> Namespace: ...
@overload
def parse_args(self, args: Optional[Sequence[_Text]], namespace: None) -> Namespace: ... # type: ignore
@overload
def parse_args(self, args: Optional[Sequence[_Text]], namespace: _N) -> _N: ...
@overload
def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore
@overload
def parse_args(self, *, namespace: _N) -> _N: ...

if sys.version_info >= (3, 7):
Expand Down