8000 stdlib: more deprecations by JelleZijlstra · Pull Request #11009 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

stdlib: more deprecations #11009

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 12 commits into from
Feb 18, 2024
Merged
Prev Previous commit
Next Next commit
Revert "Undo argparse to see if pytype becomes happier"
This reverts commit c313169.
  • Loading branch information
JelleZijlstra committed Nov 18, 2023
commit 25cf5a71ba26aa8aa40e6a9f17ac999c22c2dd26
30 changes: 27 additions & 3 deletions stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from _typeshed import sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from typing import IO, Any, Generic, NewType, NoReturn, Protocol, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
from typing_extensions import Literal, Self, TypeAlias, deprecated

__all__ = [
"ArgumentParser",
Expand Down Expand Up @@ -337,11 +337,23 @@ class Action(_AttributeHolder):

if sys.version_info >= (3, 12):
class BooleanOptionalAction(Action):
@overload
def __init__(
self,
option_strings: Sequence[str],
dest: str,
default: _T | str | None = None,
default: bool | None = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that a non-bool default doesn't really make sense on this action.

*,
required: bool = False,
help: str | None = None,
) -> None: ...
@overload
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These apparently never did anything useful, so it seems fair to emit the warning on all versions.

def __init__(
self,
option_strings: Sequence[str],
dest: str,
default: _T | bool | None = None,
type: Callable[[str], _T] | FileType | None = sentinel,
choices: Iterable[_T] | None = sentinel,
required: bool = False,
Expand All @@ -351,11 +363,23 @@ if sys.version_info >= (3, 12):

elif sys.version_info >= (3, 9):
class BooleanOptionalAction(Action):
@overload
def __init__(
self,
option_strings: Sequence[str],
dest: str,
default: bool | None = None,
*,
required: bool = False,
help: str | None = None,
) -> None: ...
@overload
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
def __init__(
self,
option_strings: Sequence[str],
dest: str,
default: _T | str | None = None,
default: _T | bool | None = None,
type: Callable[[str], _T] | FileType | None = None,
choices: Iterable[_T] | None = None,
required: bool = False,
Expand Down
0