mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 10:51:15 +08:00
Use PEP 585 syntax wherever possible (#6717)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
|
||||
from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload
|
||||
from typing import Any, Generic, NoReturn, Type, TypeVar, overload
|
||||
from typing_extensions import SupportsIndex, final
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -28,12 +28,12 @@ if sys.version_info >= (3, 7):
|
||||
rename: bool = ...,
|
||||
module: str | None = ...,
|
||||
defaults: Iterable[Any] | None = ...,
|
||||
) -> Type[Tuple[Any, ...]]: ...
|
||||
) -> Type[tuple[Any, ...]]: ...
|
||||
|
||||
else:
|
||||
def namedtuple(
|
||||
typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ...
|
||||
) -> Type[Tuple[Any, ...]]: ...
|
||||
) -> Type[tuple[Any, ...]]: ...
|
||||
|
||||
class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
data: dict[_KT, _VT]
|
||||
@@ -132,7 +132,7 @@ class UserString(Sequence[str]):
|
||||
def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ...
|
||||
else:
|
||||
def encode(self: _UserStringT, encoding: str | None = ..., errors: str | None = ...) -> _UserStringT: ...
|
||||
def endswith(self, suffix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def endswith(self, suffix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ...
|
||||
def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
|
||||
def format(self, *args: Any, **kwds: Any) -> str: ...
|
||||
@@ -174,7 +174,7 @@ class UserString(Sequence[str]):
|
||||
def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ...
|
||||
def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ...
|
||||
def splitlines(self, keepends: bool = ...) -> list[str]: ...
|
||||
def startswith(self, prefix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def startswith(self, prefix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def strip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ...
|
||||
def swapcase(self: _UserStringT) -> _UserStringT: ...
|
||||
def title(self: _UserStringT) -> _UserStringT: ...
|
||||
@@ -214,7 +214,7 @@ class deque(MutableSequence[_T], Generic[_T]):
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
|
||||
|
||||
class Counter(Dict[_T, int], Generic[_T]):
|
||||
class Counter(dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ...
|
||||
@overload
|
||||
@@ -261,14 +261,14 @@ class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # ty
|
||||
def __reversed__(self) -> Iterator[_KT_co]: ...
|
||||
|
||||
@final
|
||||
class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]): # type: ignore[misc]
|
||||
class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc]
|
||||
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
|
||||
|
||||
@final
|
||||
class _OrderedDictValuesView(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc]
|
||||
def __reversed__(self) -> Iterator[_VT_co]: ...
|
||||
|
||||
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ...
|
||||
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
@@ -286,7 +286,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
@overload
|
||||
def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> OrderedDict[_T, _S]: ...
|
||||
|
||||
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
default_factory: Callable[[], _VT] | None
|
||||
@overload
|
||||
def __init__(self, **kwargs: _VT) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user