Skip to content

Commit

Permalink
Fix stdlib stubtest after latest typing-extensions release (python#11923
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlexWaygood authored May 16, 2024
1 parent 77d6947 commit 5b0816e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ stubdefaulter==0.1.0
termcolor>=2.3
tomli==2.0.1
tomlkit==0.12.4
typing_extensions>=4.9.0rc1
typing_extensions>=4.12.0rc1
uv==0.1.27
7 changes: 7 additions & 0 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12):
__all__ += ["get_original_bases"]

if sys.version_info >= (3, 13):
__all__ += ["CapsuleType"]

# Note, all classes "defined" here require special handling.

_T1 = TypeVar("_T1")
Expand Down Expand Up @@ -607,3 +610,7 @@ if sys.version_info >= (3, 10):
def __ror__(self, value: Any, /) -> UnionType: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...

if sys.version_info >= (3, 13):
@final
class CapsuleType: ...
7 changes: 7 additions & 0 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ if sys.version_info >= (3, 11):
if sys.version_info >= (3, 12):
__all__ += ["TypeAliasType", "override"]

if sys.version_info >= (3, 13):
__all__ += ["get_protocol_members", "is_protocol", "NoDefault"]

Any = object()

def final(f: _T) -> _T: ...
Expand Down Expand Up @@ -985,3 +988,7 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13):
def is_protocol(tp: type, /) -> bool: ...
def get_protocol_members(tp: type, /) -> frozenset[str]: ...
@final
class _NoDefaultType: ...

NoDefault: _NoDefaultType
26 changes: 18 additions & 8 deletions stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ __all__ = [
"Coroutine",
"AsyncGenerator",
"AsyncContextManager",
"CapsuleType",
"ChainMap",
"ContextManager",
"Counter",
Expand Down Expand Up @@ -166,6 +167,7 @@ __all__ = [
"MutableMapping",
"MutableSequence",
"MutableSet",
"NoDefault",
"Optional",
"Pattern",
"Reversible",
Expand Down Expand Up @@ -452,13 +454,6 @@ class TypeVarTuple:
def __init__(self, name: str, *, default: Any | None = None) -> None: ...
def __iter__(self) -> Any: ... # Unpack[Self]

class deprecated:
message: LiteralString
category: type[Warning] | None
stacklevel: int
def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
def __call__(self, arg: _T, /) -> _T: ...

if sys.version_info >= (3, 12):
from collections.abc import Buffer as Buffer
from types import get_original_bases as get_original_bases
Expand Down Expand Up @@ -494,10 +489,25 @@ else:
def __buffer__(self, flags: int, /) -> memoryview: ...

if sys.version_info >= (3, 13):
from typing import get_protocol_members as get_protocol_members, is_protocol as is_protocol
from types import CapsuleType as CapsuleType
from typing import NoDefault as NoDefault, get_protocol_members as get_protocol_members, is_protocol as is_protocol
from warnings import deprecated as deprecated
else:
def is_protocol(tp: type, /) -> bool: ...
def get_protocol_members(tp: type, /) -> frozenset[str]: ...
@final
class _NoDefaultType: ...

NoDefault: _NoDefaultType
@final
class CapsuleType: ...

class deprecated:
message: LiteralString
category: type[Warning] | None
stacklevel: int
def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
def __call__(self, arg: _T, /) -> _T: ...

class Doc:
documentation: str
Expand Down
14 changes: 13 additions & 1 deletion stdlib/warnings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from _warnings import warn as warn, warn_explicit as warn_explicit
from collections.abc import Sequence
from types import ModuleType, TracebackType
from typing import Any, Generic, Literal, TextIO, TypeVar, overload
from typing_extensions import TypeAlias
from typing_extensions import LiteralString, TypeAlias

__all__ = [
"warn",
Expand All @@ -16,6 +16,10 @@ __all__ = [
"catch_warnings",
]

if sys.version_info >= (3, 13):
__all__ += ["deprecated"]

_T = TypeVar("_T")
_W = TypeVar("_W", bound=list[WarningMessage] | None)
_ActionKind: TypeAlias = Literal["default", "error", "ignore", "always", "module", "once"]

Expand Down Expand Up @@ -110,3 +114,11 @@ class catch_warnings(Generic[_W]):
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

if sys.version_info >= (3, 13):
class deprecated:
message: LiteralString
category: type[Warning] | None
stacklevel: int
def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
def __call__(self, arg: _T, /) -> _T: ...

0 comments on commit 5b0816e

Please sign in to comment.