Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3aa1f2d

Browse files
authored
typing: update and fix for py310 (#5287)
1 parent 2d69d1a commit 3aa1f2d

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

stdlib/typing.pyi

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,24 @@ if sys.version_info < (3, 7):
5656
class GenericMeta(type): ...
5757

5858
if sys.version_info >= (3, 10):
59+
class ParamSpecArgs:
60+
__origin__: ParamSpec
61+
def __init__(self, origin: ParamSpec) -> None: ...
62+
class ParamSpecKwargs:
63+
__origin__: ParamSpec
64+
def __init__(self, origin: ParamSpec) -> None: ...
5965
class ParamSpec:
6066
__name__: str
61-
def __init__(self, name: str) -> None: ...
67+
__bound__: Optional[Type[Any]]
68+
__covariant__: bool
69+
__contravariant__: bool
70+
def __init__(
71+
self, name: str, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ...
72+
) -> None: ...
73+
@property
74+
def args(self) -> ParamSpecArgs: ...
75+
@property
76+
def kwargs(self) -> ParamSpecKwargs: ...
6277
Concatenate: _SpecialForm = ...
6378
TypeAlias: _SpecialForm = ...
6479
TypeGuard: _SpecialForm = ...
@@ -681,3 +696,6 @@ if sys.version_info >= (3, 7):
681696
def __eq__(self, other: Any) -> bool: ...
682697
def __hash__(self) -> int: ...
683698
def __repr__(self) -> str: ...
699+
700+
if sys.version_info >= (3, 10):
701+
def is_typeddict(tp: Any) -> bool: ...

stdlib/typing_extensions.pyi

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ from typing import (
2020
Tuple,
2121
Type as Type,
2222
TypeVar,
23+
Union,
2324
ValuesView,
2425
overload as overload,
2526
)
@@ -96,22 +97,33 @@ if sys.version_info >= (3, 7):
9697
Annotated: _SpecialForm = ...
9798
_AnnotatedAlias: Any = ... # undocumented
9899

99-
# TypeAlias is a (non-subscriptable) special form.
100-
class TypeAlias: ...
101-
102100
@runtime_checkable
103101
class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
104102
@abc.abstractmethod
105103
def __index__(self) -> int: ...
106104

107105
# PEP 612 support for Python < 3.9
108106
if sys.version_info >= (3, 10):
109-
from typing import Concatenate as Concatenate, ParamSpec as ParamSpec
107+
from typing import Concatenate as Concatenate, ParamSpec as ParamSpec, TypeAlias as TypeAlias, TypeGuard as TypeGuard
110108
else:
109+
class ParamSpecArgs:
110+
__origin__: ParamSpec
111+
def __init__(self, origin: ParamSpec) -> None: ...
112+
class ParamSpecKwargs:
113+
__origin__: ParamSpec
114+
def __init__(self, origin: ParamSpec) -> None: ...
111115
class ParamSpec:
112116
__name__: str
113-
def __init__(self, name: str) -> None: ...
117+
__bound__: Optional[Type[Any]]
118+
__covariant__: bool
119+
__contravariant__: bool
120+
def __init__(
121+
self, name: str, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ...
122+
) -> None: ...
123+
@property
124+
def args(self) -> ParamSpecArgs: ...
125+
@property
126+
def kwargs(self) -> ParamSpecKwargs: ...
114127
Concatenate: _SpecialForm = ...
115-
116-
# PEP 647
117-
TypeGuard: _SpecialForm = ...
128+
TypeAlias: _SpecialForm = ...
129+
TypeGuard: _SpecialForm = ...

0 commit comments

Comments
 (0)