mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Fixes to typing and typing_extensions stubs (#11086)
This commit is contained in:
@@ -20,7 +20,7 @@ stubdefaulter==0.1.0
|
||||
termcolor>=2.3
|
||||
tomli==2.0.1
|
||||
tomlkit==0.12.3
|
||||
typing_extensions>=4.8.0
|
||||
typing_extensions>=4.9.0rc1
|
||||
|
||||
# Type stubs used to type check our scripts.
|
||||
types-pyyaml>=6.0.12.7
|
||||
|
||||
@@ -281,7 +281,12 @@ if sys.version_info >= (3, 10):
|
||||
|
||||
class NewType:
|
||||
def __init__(self, name: str, tp: Any) -> None: ...
|
||||
def __call__(self, __x: _T) -> _T: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
@staticmethod
|
||||
def __call__(__x: _T) -> _T: ...
|
||||
else:
|
||||
def __call__(self, x: _T) -> _T: ...
|
||||
|
||||
def __or__(self, other: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, other: Any) -> _SpecialForm: ...
|
||||
__supertype__: type
|
||||
|
||||
@@ -182,6 +182,7 @@ __all__ = [
|
||||
"is_protocol",
|
||||
"no_type_check",
|
||||
"no_type_check_decorator",
|
||||
"ReadOnly",
|
||||
]
|
||||
|
||||
_T = typing.TypeVar("_T")
|
||||
@@ -220,6 +221,8 @@ def IntVar(name: str) -> Any: ... # returns a new TypeVar
|
||||
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
__required_keys__: ClassVar[frozenset[str]]
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
__readonly_keys__: ClassVar[frozenset[str]]
|
||||
__mutable_keys__: ClassVar[frozenset[str]]
|
||||
__total__: ClassVar[bool]
|
||||
__orig_bases__: ClassVar[tuple[Any, ...]]
|
||||
def copy(self) -> Self: ...
|
||||
@@ -283,7 +286,6 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import (
|
||||
Concatenate as Concatenate,
|
||||
NewType as NewType,
|
||||
ParamSpecArgs as ParamSpecArgs,
|
||||
ParamSpecKwargs as ParamSpecKwargs,
|
||||
TypeAlias as TypeAlias,
|
||||
@@ -308,18 +310,13 @@ else:
|
||||
TypeGuard: _SpecialForm
|
||||
def is_typeddict(tp: object) -> bool: ...
|
||||
|
||||
class NewType:
|
||||
def __init__(self, name: str, tp: Any) -> None: ...
|
||||
def __call__(self, __x: _T) -> _T: ...
|
||||
__supertype__: type
|
||||
|
||||
# New things in 3.11
|
||||
# NamedTuples are not new, but the ability to create generic NamedTuples is new in 3.11
|
||||
# New and changed things in 3.11
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import (
|
||||
LiteralString as LiteralString,
|
||||
NamedTuple as NamedTuple,
|
||||
Never as Never,
|
||||
NewType as NewType,
|
||||
NotRequired as NotRequired,
|
||||
Required as Required,
|
||||
Self as Self,
|
||||
@@ -376,6 +373,14 @@ else:
|
||||
|
||||
def _replace(self, **kwargs: Any) -> Self: ...
|
||||
|
||||
class NewType:
|
||||
def __init__(self, name: str, tp: Any) -> None: ...
|
||||
def __call__(self, __obj: _T) -> _T: ...
|
||||
__supertype__: type
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, other: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, other: Any) -> _SpecialForm: ...
|
||||
|
||||
# New things in 3.xx
|
||||
# The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)
|
||||
# The `infer_variance` parameter was added to TypeVar in 3.12 (PEP 695)
|
||||
@@ -449,7 +454,12 @@ class TypeVarTuple:
|
||||
def __init__(self, name: str, *, default: Any | None = None) -> None: ...
|
||||
def __iter__(self) -> Any: ... # Unpack[Self]
|
||||
|
||||
def deprecated(__msg: str, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> Callable[[_T], _T]: ...
|
||||
class deprecated:
|
||||
message: str
|
||||
category: type[Warning] | None
|
||||
stacklevel: int
|
||||
def __init__(self, __message: str, *, 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
|
||||
@@ -496,3 +506,5 @@ class Doc:
|
||||
def __init__(self, __documentation: str) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
ReadOnly: _SpecialForm
|
||||
|
||||
@@ -149,9 +149,6 @@ dataclasses.KW_ONLY
|
||||
# We pretend it's a read-only property for forward compatibility with 3.12
|
||||
typing.ParamSpec(Args|Kwargs).__origin__
|
||||
|
||||
# https://github.com/python/mypy/issues/15302
|
||||
typing.NewType.__call__
|
||||
|
||||
# Problematic protocol signatures at runtime, see source code comments.
|
||||
importlib.abc.Traversable.joinpath
|
||||
importlib.abc.Traversable.open
|
||||
|
||||
@@ -14,7 +14,6 @@ enum.Enum._generate_next_value_
|
||||
enum.StrEnum._generate_next_value_
|
||||
importlib.abc.Finder.find_module
|
||||
tkinter._VersionInfoType.__doc__
|
||||
typing.NewType.__call__
|
||||
typing.NewType.__mro_entries__
|
||||
|
||||
# Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
|
||||
@@ -12,7 +12,6 @@ _csv.Writer
|
||||
configparser.LegacyInterpolation.__init__
|
||||
enum.Enum.__init__
|
||||
tkinter._VersionInfoType.__doc__
|
||||
typing.NewType.__call__
|
||||
typing.NewType.__mro_entries__
|
||||
|
||||
# ==========
|
||||
@@ -103,7 +102,6 @@ typing\._SpecialForm.*
|
||||
typing\.NamedTuple
|
||||
typing\.LiteralString
|
||||
typing\.Annotated
|
||||
typing_extensions\.Protocol
|
||||
|
||||
# These only exist to give a better error message if you try to subclass an instance
|
||||
typing.ParamSpec.__mro_entries__
|
||||
|
||||
@@ -523,9 +523,6 @@ typing(_extensions)?\.AbstractSet
|
||||
|
||||
typing_extensions.NewType.__mro_entries__ # just exists for an error message
|
||||
|
||||
# https://github.com/python/mypy/issues/15302
|
||||
typing_extensions.NewType.__call__
|
||||
|
||||
# Typing-related weirdness
|
||||
_collections_abc.Callable
|
||||
_typeshed.* # Utility types for typeshed, doesn't exist at runtime
|
||||
|
||||
Reference in New Issue
Block a user