mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Fix conditional imports within collections (#5040)
Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
import sys
|
||||
import typing
|
||||
from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
from _collections_abc import *
|
||||
else:
|
||||
from typing import (
|
||||
Callable,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
KeysView,
|
||||
Mapping,
|
||||
MutableMapping,
|
||||
MutableSequence,
|
||||
Reversible,
|
||||
Sequence,
|
||||
ValuesView,
|
||||
)
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
@@ -103,7 +116,7 @@ class UserString(Sequence[str]):
|
||||
def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
|
||||
def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ...
|
||||
def encode(self: UserString, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ...
|
||||
else:
|
||||
def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ...
|
||||
def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
|
||||
@@ -281,9 +294,9 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
|
||||
@property
|
||||
def maps(self) -> List[Mapping[_KT, _VT]]: ...
|
||||
def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ...
|
||||
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
|
||||
@property
|
||||
def parents(self) -> typing.ChainMap[_KT, _VT]: ...
|
||||
def parents(self) -> ChainMap[_KT, _VT]: ...
|
||||
def __setitem__(self, k: _KT, v: _VT) -> None: ...
|
||||
def __delitem__(self, v: _KT) -> None: ...
|
||||
def __getitem__(self, k: _KT) -> _VT: ...
|
||||
|
||||
Reference in New Issue
Block a user