mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Use _typeshed.Self in Python 2, too (#6932)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from _typeshed import Self
|
||||
from typing import Iterable, List, MutableSequence, TypeVar, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class UserList(MutableSequence[_T]):
|
||||
data: List[_T]
|
||||
@@ -15,5 +15,5 @@ class UserList(MutableSequence[_T]):
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _T: ...
|
||||
@overload
|
||||
def __getitem__(self: _S, s: slice) -> _S: ...
|
||||
def __getitem__(self: Self, s: slice) -> Self: ...
|
||||
def sort(self) -> None: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, overload
|
||||
|
||||
_UST = TypeVar("_UST", bound=UserString)
|
||||
_MST = TypeVar("_MST", bound=MutableString)
|
||||
|
||||
class UserString(Sequence[UserString]):
|
||||
@@ -13,21 +13,21 @@ class UserString(Sequence[UserString]):
|
||||
def __hash__(self) -> int: ...
|
||||
def __len__(self) -> int: ...
|
||||
@overload
|
||||
def __getitem__(self: _UST, i: int) -> _UST: ...
|
||||
def __getitem__(self: Self, i: int) -> Self: ...
|
||||
@overload
|
||||
def __getitem__(self: _UST, s: slice) -> _UST: ...
|
||||
def __add__(self: _UST, other: Any) -> _UST: ...
|
||||
def __radd__(self: _UST, other: Any) -> _UST: ...
|
||||
def __mul__(self: _UST, other: int) -> _UST: ...
|
||||
def __rmul__(self: _UST, other: int) -> _UST: ...
|
||||
def __mod__(self: _UST, args: Any) -> _UST: ...
|
||||
def capitalize(self: _UST) -> _UST: ...
|
||||
def center(self: _UST, width: int, *args: Any) -> _UST: ...
|
||||
def __getitem__(self: Self, s: slice) -> Self: ...
|
||||
def __add__(self: Self, other: Any) -> Self: ...
|
||||
def __radd__(self: Self, other: Any) -> Self: ...
|
||||
def __mul__(self: Self, other: int) -> Self: ...
|
||||
def __rmul__(self: Self, other: int) -> Self: ...
|
||||
def __mod__(self: Self, args: Any) -> Self: ...
|
||||
def capitalize(self: Self) -> Self: ...
|
||||
def center(self: Self, width: int, *args: Any) -> Self: ...
|
||||
def count(self, sub: int, start: int = ..., end: int = ...) -> int: ...
|
||||
def decode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
|
||||
def encode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
|
||||
def decode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
|
||||
def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
|
||||
def endswith(self, suffix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ...
|
||||
def expandtabs(self: Self, tabsize: int = ...) -> Self: ...
|
||||
def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
|
||||
def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
|
||||
def isalpha(self) -> bool: ...
|
||||
@@ -40,35 +40,35 @@ class UserString(Sequence[UserString]):
|
||||
def istitle(self) -> bool: ...
|
||||
def isupper(self) -> bool: ...
|
||||
def join(self, seq: Iterable[Text]) -> Text: ...
|
||||
def ljust(self: _UST, width: int, *args: Any) -> _UST: ...
|
||||
def lower(self: _UST) -> _UST: ...
|
||||
def lstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
|
||||
def ljust(self: Self, width: int, *args: Any) -> Self: ...
|
||||
def lower(self: Self) -> Self: ...
|
||||
def lstrip(self: Self, chars: Text | None = ...) -> Self: ...
|
||||
def partition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
|
||||
def replace(self: _UST, old: Text, new: Text, maxsplit: int = ...) -> _UST: ...
|
||||
def replace(self: Self, old: Text, new: Text, maxsplit: int = ...) -> Self: ...
|
||||
def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
|
||||
def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
|
||||
def rjust(self: _UST, width: int, *args: Any) -> _UST: ...
|
||||
def rjust(self: Self, width: int, *args: Any) -> Self: ...
|
||||
def rpartition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
|
||||
def rstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
|
||||
def rstrip(self: Self, chars: Text | None = ...) -> Self: ...
|
||||
def split(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
|
||||
def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
|
||||
def splitlines(self, keepends: int = ...) -> List[Text]: ...
|
||||
def startswith(self, prefix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
|
||||
def strip(self: _UST, chars: Text | None = ...) -> _UST: ...
|
||||
def swapcase(self: _UST) -> _UST: ...
|
||||
def title(self: _UST) -> _UST: ...
|
||||
def translate(self: _UST, *args: Any) -> _UST: ...
|
||||
def upper(self: _UST) -> _UST: ...
|
||||
def zfill(self: _UST, width: int) -> _UST: ...
|
||||
def strip(self: Self, chars: Text | None = ...) -> Self: ...
|
||||
def swapcase(self: Self) -> Self: ...
|
||||
def title(self: Self) -> Self: ...
|
||||
def translate(self: Self, *args: Any) -> Self: ...
|
||||
def upper(self: Self) -> Self: ...
|
||||
def zfill(self: Self, width: int) -> Self: ...
|
||||
|
||||
class MutableString(UserString, MutableSequence[MutableString]):
|
||||
@overload
|
||||
def __getitem__(self: _MST, i: int) -> _MST: ...
|
||||
def __getitem__(self: Self, i: int) -> Self: ...
|
||||
@overload
|
||||
def __getitem__(self: _MST, s: slice) -> _MST: ...
|
||||
def __getitem__(self: Self, s: slice) -> Self: ...
|
||||
def __setitem__(self, index: int | slice, sub: Any) -> None: ...
|
||||
def __delitem__(self, index: int | slice) -> None: ...
|
||||
def immutable(self) -> UserString: ...
|
||||
def __iadd__(self: _MST, other: Any) -> _MST: ...
|
||||
def __iadd__(self: Self, other: Any) -> Self: ...
|
||||
def __imul__(self, n: int) -> _MST: ...
|
||||
def insert(self, index: int, value: Any) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# True and False are deliberately omitted because they are keywords in
|
||||
# Python 3, and stub files conform to Python 3 syntax.
|
||||
|
||||
from _typeshed import ReadableBuffer, SupportsKeysAndGetItem, SupportsWrite
|
||||
from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite
|
||||
from abc import ABCMeta
|
||||
from ast import mod
|
||||
from types import CodeType
|
||||
@@ -651,7 +651,7 @@ class list(MutableSequence[_T], Generic[_T]):
|
||||
def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ...
|
||||
def __delslice__(self, start: int, stop: int) -> None: ...
|
||||
def __add__(self, x: List[_T]) -> List[_T]: ...
|
||||
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
|
||||
def __iadd__(self: Self, x: Iterable[_T]) -> Self: ...
|
||||
def __mul__(self, n: int) -> List[_T]: ...
|
||||
def __rmul__(self, n: int) -> List[_T]: ...
|
||||
def __contains__(self, o: object) -> bool: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Dict, Generic, Iterator, TypeVar
|
||||
|
||||
_K = TypeVar("_K")
|
||||
@@ -9,8 +10,8 @@ class defaultdict(Dict[_K, _V]):
|
||||
default_factory: None
|
||||
def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ...
|
||||
def __missing__(self, key: _K) -> _V: ...
|
||||
def __copy__(self: _T) -> _T: ...
|
||||
def copy(self: _T) -> _T: ...
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
|
||||
class deque(Generic[_T]):
|
||||
maxlen: int | None
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed import Self
|
||||
from mmap import mmap
|
||||
from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, TypeVar, Union
|
||||
from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, Union
|
||||
|
||||
_bytearray_like = Union[bytearray, mmap]
|
||||
|
||||
@@ -11,8 +11,6 @@ class BlockingIOError(IOError):
|
||||
|
||||
class UnsupportedOperation(ValueError, IOError): ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _IOBase(BinaryIO):
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
@@ -33,7 +31,7 @@ class _IOBase(BinaryIO):
|
||||
def writable(self) -> bool: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ...
|
||||
def __iter__(self: _T) -> _T: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
# The parameter type of writelines[s]() is determined by that of write():
|
||||
def writelines(self, lines: Iterable[bytes]) -> None: ...
|
||||
# The return type of readline[s]() and next() is determined by that of read():
|
||||
@@ -141,7 +139,7 @@ class _TextIOBase(TextIO):
|
||||
def writelines(self, lines: Iterable[unicode]) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ...
|
||||
def __iter__(self: _T) -> _T: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
|
||||
class StringIO(_TextIOBase):
|
||||
line_buffering: bool
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
_SelfT = TypeVar("_SelfT", bound=WeakSet[Any])
|
||||
|
||||
class WeakSet(MutableSet[_T], Generic[_T]):
|
||||
def __init__(self, data: Iterable[_T] | None = ...) -> None: ...
|
||||
def add(self, item: _T) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def discard(self, item: _T) -> None: ...
|
||||
def copy(self: _SelfT) -> _SelfT: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
def pop(self) -> _T: ...
|
||||
def remove(self, item: _T) -> None: ...
|
||||
def update(self, other: Iterable[_T]) -> None: ...
|
||||
@@ -17,14 +17,14 @@ class WeakSet(MutableSet[_T], Generic[_T]):
|
||||
def __len__(self) -> int: ...
|
||||
def __iter__(self) -> Iterator[_T]: ...
|
||||
def __ior__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
|
||||
def difference(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def __sub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def difference(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def __sub__(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def difference_update(self, other: Iterable[_T]) -> None: ...
|
||||
def __isub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def intersection(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def __and__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def __isub__(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def intersection(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def __and__(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def intersection_update(self, other: Iterable[_T]) -> None: ...
|
||||
def __iand__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
|
||||
def __iand__(self: Self, other: Iterable[_T]) -> Self: ...
|
||||
def issubset(self, other: Iterable[_T]) -> bool: ...
|
||||
def __le__(self, other: Iterable[_T]) -> bool: ...
|
||||
def __lt__(self, other: Iterable[_T]) -> bool: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# True and False are deliberately omitted because they are keywords in
|
||||
# Python 3, and stub files conform to Python 3 syntax.
|
||||
|
||||
from _typeshed import ReadableBuffer, SupportsKeysAndGetItem, SupportsWrite
|
||||
from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite
|
||||
from abc import ABCMeta
|
||||
from ast import mod
|
||||
from types import CodeType
|
||||
@@ -651,7 +651,7 @@ class list(MutableSequence[_T], Generic[_T]):
|
||||
def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ...
|
||||
def __delslice__(self, start: int, stop: int) -> None: ...
|
||||
def __add__(self, x: List[_T]) -> List[_T]: ...
|
||||
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
|
||||
def __iadd__(self: Self, x: Iterable[_T]) -> Self: ...
|
||||
def __mul__(self, n: int) -> List[_T]: ...
|
||||
def __rmul__(self, n: int) -> List[_T]: ...
|
||||
def __contains__(self, o: object) -> bool: ...
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import io
|
||||
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||
from typing import IO, Any, Iterable, List, Text, TypeVar, Union
|
||||
from _typeshed import ReadableBuffer, Self, WriteableBuffer
|
||||
from typing import IO, Any, Iterable, List, Text, Union
|
||||
from typing_extensions import SupportsIndex
|
||||
|
||||
_PathOrFile = Union[Text, IO[bytes]]
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
|
||||
def decompress(data: bytes) -> bytes: ...
|
||||
|
||||
class BZ2File(io.BufferedIOBase, IO[bytes]):
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __init__(self, filename: _PathOrFile, mode: str = ..., buffering: Any | None = ..., compresslevel: int = ...) -> None: ...
|
||||
def read(self, size: int | None = ...) -> bytes: ...
|
||||
def read1(self, size: int = ...) -> bytes: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from types import CodeType
|
||||
from typing import Any, Callable, Dict, Text, Tuple, TypeVar
|
||||
|
||||
@@ -6,7 +7,6 @@ def runctx(
|
||||
statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ...
|
||||
) -> None: ...
|
||||
|
||||
_SelfT = TypeVar("_SelfT", bound=Profile)
|
||||
_T = TypeVar("_T")
|
||||
_Label = Tuple[str, int, str]
|
||||
|
||||
@@ -21,8 +21,8 @@ class Profile:
|
||||
def dump_stats(self, file: Text) -> None: ...
|
||||
def create_stats(self) -> None: ...
|
||||
def snapshot_stats(self) -> None: ...
|
||||
def run(self: _SelfT, cmd: str) -> _SelfT: ...
|
||||
def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ...
|
||||
def run(self: Self, cmd: str) -> Self: ...
|
||||
def runctx(self: Self, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> Self: ...
|
||||
def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...
|
||||
|
||||
def label(code: str | CodeType) -> _Label: ... # undocumented
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from typing import (
|
||||
IO,
|
||||
@@ -14,7 +15,6 @@ from typing import (
|
||||
TextIO,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
@@ -189,8 +189,6 @@ class BufferedIncrementalDecoder(IncrementalDecoder):
|
||||
def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ...
|
||||
def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ...
|
||||
|
||||
_SW = TypeVar("_SW", bound=StreamWriter)
|
||||
|
||||
# TODO: it is not possible to specify the requirement that all other
|
||||
# attributes and methods are passed-through from the stream.
|
||||
class StreamWriter(Codec):
|
||||
@@ -199,12 +197,10 @@ class StreamWriter(Codec):
|
||||
def write(self, object: _Decoded) -> None: ...
|
||||
def writelines(self, list: Iterable[_Decoded]) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
def __enter__(self: _SW) -> _SW: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
|
||||
|
||||
_SR = TypeVar("_SR", bound=StreamReader)
|
||||
|
||||
class StreamReader(Codec):
|
||||
errors: str
|
||||
def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...
|
||||
@@ -212,13 +208,11 @@ class StreamReader(Codec):
|
||||
def readline(self, size: int | None = ..., keepends: bool = ...) -> _Decoded: ...
|
||||
def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[_Decoded]: ...
|
||||
def reset(self) -> None: ...
|
||||
def __enter__(self: _SR) -> _SR: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
def __iter__(self) -> Iterator[_Decoded]: ...
|
||||
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
|
||||
|
||||
_T = TypeVar("_T", bound=StreamReaderWriter)
|
||||
|
||||
# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing
|
||||
# and delegates attributes to the underlying binary stream with __getattr__.
|
||||
class StreamReaderWriter(TextIO):
|
||||
@@ -227,14 +221,14 @@ class StreamReaderWriter(TextIO):
|
||||
def readline(self, size: int | None = ...) -> _Decoded: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> List[_Decoded]: ...
|
||||
def next(self) -> Text: ...
|
||||
def __iter__(self: _T) -> _T: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
# This actually returns None, but that's incompatible with the supertype
|
||||
def write(self, data: _Decoded) -> int: ...
|
||||
def writelines(self, list: Iterable[_Decoded]) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
# Same as write()
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
|
||||
@@ -249,8 +243,6 @@ class StreamReaderWriter(TextIO):
|
||||
def tell(self) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
|
||||
_SRT = TypeVar("_SRT", bound=StreamRecoder)
|
||||
|
||||
class StreamRecoder(BinaryIO):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -265,12 +257,12 @@ class StreamRecoder(BinaryIO):
|
||||
def readline(self, size: int | None = ...) -> bytes: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> List[bytes]: ...
|
||||
def next(self) -> bytes: ...
|
||||
def __iter__(self: _SRT) -> _SRT: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def write(self, data: bytes) -> int: ...
|
||||
def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None
|
||||
def reset(self) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __enter__(self: _SRT) -> _SRT: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
|
||||
# interface. At runtime, they are delegated through __getattr__.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from typing import (
|
||||
AbstractSet,
|
||||
Any,
|
||||
@@ -28,7 +29,6 @@ from typing import (
|
||||
|
||||
Set = AbstractSet
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
@@ -61,7 +61,7 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
|
||||
def __setitem__(self, i: int, x: _T) -> None: ...
|
||||
def __contains__(self, o: _T) -> bool: ...
|
||||
def __reversed__(self) -> Iterator[_T]: ...
|
||||
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
|
||||
def __iadd__(self: Self, iterable: Iterable[_T]) -> Self: ...
|
||||
|
||||
class Counter(Dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
@@ -70,7 +70,7 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
|
||||
@overload
|
||||
def __init__(self, iterable: Iterable[_T]) -> None: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
def elements(self) -> Iterator[_T]: ...
|
||||
def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ...
|
||||
@overload
|
||||
@@ -99,7 +99,7 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
|
||||
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
|
||||
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
@@ -119,4 +119,4 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
@overload
|
||||
def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def __missing__(self, key: _KT) -> _VT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from typing import Pattern, Text, Tuple, TypeVar
|
||||
|
||||
@@ -8,7 +9,7 @@ class Version:
|
||||
@abstractmethod
|
||||
def __init__(self, vstring: Text | None = ...) -> None: ...
|
||||
@abstractmethod
|
||||
def parse(self: _T, vstring: Text) -> _T: ...
|
||||
def parse(self: Self, vstring: Text) -> Self: ...
|
||||
@abstractmethod
|
||||
def __str__(self) -> str: ...
|
||||
@abstractmethod
|
||||
@@ -19,7 +20,7 @@ class StrictVersion(Version):
|
||||
version: Tuple[int, int, int]
|
||||
prerelease: Tuple[Text, int] | None
|
||||
def __init__(self, vstring: Text | None = ...) -> None: ...
|
||||
def parse(self: _T, vstring: Text) -> _T: ...
|
||||
def parse(self: Self, vstring: Text) -> Self: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __cmp__(self: _T, other: _T | str) -> bool: ...
|
||||
|
||||
@@ -28,6 +29,6 @@ class LooseVersion(Version):
|
||||
vstring: Text
|
||||
version: Tuple[Text | int, ...]
|
||||
def __init__(self, vstring: Text | None = ...) -> None: ...
|
||||
def parse(self: _T, vstring: Text) -> _T: ...
|
||||
def parse(self: Self, vstring: Text) -> Self: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __cmp__(self: _T, other: _T | str) -> bool: ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from _typeshed import StrPath
|
||||
from typing import Dict, List, Optional, Text, Tuple, TypeVar
|
||||
from _typeshed import Self, StrPath
|
||||
from typing import Dict, List, Optional, Text, Tuple
|
||||
|
||||
_P = TypeVar("_P")
|
||||
_Label = Tuple[int, Optional[Text]]
|
||||
_DFA = List[List[Tuple[int, int]]]
|
||||
_DFAS = Tuple[_DFA, Dict[int, int]]
|
||||
@@ -19,7 +18,7 @@ class Grammar:
|
||||
def __init__(self) -> None: ...
|
||||
def dump(self, filename: StrPath) -> None: ...
|
||||
def load(self, filename: StrPath) -> None: ...
|
||||
def copy(self: _P) -> _P: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
def report(self) -> None: ...
|
||||
|
||||
opmap_raw: Text
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from lib2to3.pgen2.grammar import Grammar
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union
|
||||
|
||||
@@ -21,7 +22,7 @@ class Base:
|
||||
was_checked: bool
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def _eq(self: _P, other: _P) -> bool: ...
|
||||
def clone(self: _P) -> _P: ...
|
||||
def clone(self: Self) -> Self: ...
|
||||
def post_order(self) -> Iterator[_NL]: ...
|
||||
def pre_order(self) -> Iterator[_NL]: ...
|
||||
def replace(self, new: _NL | List[_NL]) -> None: ...
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import datetime
|
||||
import socket
|
||||
import ssl
|
||||
from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, TypeVar, Union
|
||||
from _typeshed import Self
|
||||
from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, Union
|
||||
|
||||
_SelfT = TypeVar("_SelfT", bound=_NNTPBase)
|
||||
_File = Union[IO[bytes], bytes, str, None]
|
||||
|
||||
class NNTPError(Exception):
|
||||
@@ -45,7 +45,7 @@ class _NNTPBase:
|
||||
nntp_implementation: str
|
||||
nntp_version: int
|
||||
def __init__(self, file: IO[bytes], host: str, readermode: bool | None = ..., timeout: float = ...) -> None: ...
|
||||
def __enter__(self: _SelfT) -> _SelfT: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def getwelcome(self) -> str: ...
|
||||
def getcapabilities(self) -> Dict[str, List[str]]: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Dict, Text, Tuple, TypeVar
|
||||
|
||||
def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ...
|
||||
@@ -5,7 +6,6 @@ def runctx(
|
||||
statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ...
|
||||
) -> None: ...
|
||||
|
||||
_SelfT = TypeVar("_SelfT", bound=Profile)
|
||||
_T = TypeVar("_T")
|
||||
_Label = Tuple[str, int, str]
|
||||
|
||||
@@ -20,7 +20,7 @@ class Profile:
|
||||
def dump_stats(self, file: Text) -> None: ...
|
||||
def create_stats(self) -> None: ...
|
||||
def snapshot_stats(self) -> None: ...
|
||||
def run(self: _SelfT, cmd: str) -> _SelfT: ...
|
||||
def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ...
|
||||
def run(self: Self, cmd: str) -> Self: ...
|
||||
def runctx(self: Self, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> Self: ...
|
||||
def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...
|
||||
def calibrate(self, m: int, verbose: int = ...) -> float: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from cProfile import Profile as _cProfile
|
||||
from profile import Profile
|
||||
from typing import IO, Any, Dict, Iterable, List, Text, Tuple, TypeVar, Union, overload
|
||||
@@ -16,21 +17,21 @@ class Stats:
|
||||
def init(self, arg: None | str | Text | Profile | _cProfile) -> None: ...
|
||||
def load_stats(self, arg: None | str | Text | Profile | _cProfile) -> None: ...
|
||||
def get_top_level_stats(self) -> None: ...
|
||||
def add(self: _T, *arg_list: None | str | Text | Profile | _cProfile | _T) -> _T: ...
|
||||
def add(self: Self, *arg_list: None | str | Text | Profile | _cProfile | Self) -> Self: ...
|
||||
def dump_stats(self, filename: Text) -> None: ...
|
||||
def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ...
|
||||
@overload
|
||||
def sort_stats(self: _T, field: int) -> _T: ...
|
||||
def sort_stats(self: Self, field: int) -> Self: ...
|
||||
@overload
|
||||
def sort_stats(self: _T, *field: str) -> _T: ...
|
||||
def reverse_order(self: _T) -> _T: ...
|
||||
def strip_dirs(self: _T) -> _T: ...
|
||||
def sort_stats(self: Self, *field: str) -> Self: ...
|
||||
def reverse_order(self: Self) -> Self: ...
|
||||
def strip_dirs(self: Self) -> Self: ...
|
||||
def calc_callees(self) -> None: ...
|
||||
def eval_print_amount(self, sel: _Selector, list: List[str], msg: str) -> Tuple[List[str], str]: ...
|
||||
def get_print_list(self, sel_list: Iterable[_Selector]) -> Tuple[int, List[str]]: ...
|
||||
def print_stats(self: _T, *amount: _Selector) -> _T: ...
|
||||
def print_callees(self: _T, *amount: _Selector) -> _T: ...
|
||||
def print_callers(self: _T, *amount: _Selector) -> _T: ...
|
||||
def print_stats(self: Self, *amount: _Selector) -> Self: ...
|
||||
def print_callees(self: Self, *amount: _Selector) -> Self: ...
|
||||
def print_callers(self: Self, *amount: _Selector) -> Self: ...
|
||||
def print_call_heading(self, name_size: int, column_title: str) -> None: ...
|
||||
def print_call_line(self, name_size: int, source: str, call_dict: Dict[str, Any], arrow: str = ...) -> None: ...
|
||||
def print_title(self) -> None: ...
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar, Union
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Setlike = Union[BaseSet[_T], Iterable[_T]]
|
||||
_SelfT = TypeVar("_SelfT")
|
||||
|
||||
class BaseSet(Iterable[_T]):
|
||||
def __init__(self) -> None: ...
|
||||
@@ -13,17 +13,17 @@ class BaseSet(Iterable[_T]):
|
||||
def __cmp__(self, other: Any) -> int: ...
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __ne__(self, other: Any) -> bool: ...
|
||||
def copy(self: _SelfT) -> _SelfT: ...
|
||||
def __copy__(self: _SelfT) -> _SelfT: ...
|
||||
def __deepcopy__(self: _SelfT, memo: MutableMapping[int, BaseSet[_T]]) -> _SelfT: ...
|
||||
def __or__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def union(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
|
||||
def __and__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def intersection(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
|
||||
def __xor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def symmetric_difference(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
|
||||
def __sub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def difference(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
def __deepcopy__(self: Self, memo: MutableMapping[int, BaseSet[_T]]) -> Self: ...
|
||||
def __or__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def union(self: Self, other: _Setlike[_T]) -> Self: ...
|
||||
def __and__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def intersection(self: Self, other: _Setlike[Any]) -> Self: ...
|
||||
def __xor__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def symmetric_difference(self: Self, other: _Setlike[_T]) -> Self: ...
|
||||
def __sub__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def difference(self: Self, other: _Setlike[Any]) -> Self: ...
|
||||
def __contains__(self, element: Any) -> bool: ...
|
||||
def issubset(self, other: BaseSet[_T]) -> bool: ...
|
||||
def issuperset(self, other: BaseSet[_T]) -> bool: ...
|
||||
@@ -38,13 +38,13 @@ class ImmutableSet(BaseSet[_T], Hashable):
|
||||
|
||||
class Set(BaseSet[_T]):
|
||||
def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ...
|
||||
def __ior__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def __ior__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def union_update(self, other: _Setlike[_T]) -> None: ...
|
||||
def __iand__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def __iand__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def intersection_update(self, other: _Setlike[Any]) -> None: ...
|
||||
def __ixor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def __ixor__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def symmetric_difference_update(self, other: _Setlike[_T]) -> None: ...
|
||||
def __isub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
|
||||
def __isub__(self: Self, other: BaseSet[_T]) -> Self: ...
|
||||
def difference_update(self, other: _Setlike[Any]) -> None: ...
|
||||
def update(self, iterable: _Setlike[_T]) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from typing import IO, Any, List, Text, TypeVar
|
||||
from _typeshed import Self
|
||||
from typing import IO, Any, List, Text
|
||||
|
||||
def split(s: str | None, comments: bool = ..., posix: bool = ...) -> List[str]: ...
|
||||
|
||||
_SLT = TypeVar("_SLT", bound=shlex)
|
||||
|
||||
class shlex:
|
||||
def __init__(self, instream: IO[Any] | Text = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ...
|
||||
def __iter__(self: _SLT) -> _SLT: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def next(self) -> str: ...
|
||||
def get_token(self) -> str | None: ...
|
||||
def push_token(self, _str: str) -> None: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, Callable, Dict, List, Sequence, Text, Tuple, TypeVar, Union, overload
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Dict, List, Sequence, Text, Tuple, Union, overload
|
||||
|
||||
# TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module.
|
||||
Canvas = Any
|
||||
@@ -199,8 +200,6 @@ class TPen(object):
|
||||
st = showturtle
|
||||
ht = hideturtle
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class RawTurtle(TPen, TNavigator):
|
||||
def __init__(
|
||||
self, canvas: Canvas | TurtleScreen | None = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ...
|
||||
@@ -209,7 +208,7 @@ class RawTurtle(TPen, TNavigator):
|
||||
def setundobuffer(self, size: int | None) -> None: ...
|
||||
def undobufferentries(self) -> int: ...
|
||||
def clear(self) -> None: ...
|
||||
def clone(self: _T) -> _T: ...
|
||||
def clone(self: Self) -> Self: ...
|
||||
@overload
|
||||
def shape(self, name: None = ...) -> str: ...
|
||||
@overload
|
||||
@@ -242,7 +241,7 @@ class RawTurtle(TPen, TNavigator):
|
||||
def end_poly(self) -> None: ...
|
||||
def get_poly(self) -> _PolygonCoords | None: ...
|
||||
def getscreen(self) -> TurtleScreen: ...
|
||||
def getturtle(self: _T) -> _T: ...
|
||||
def getturtle(self: Self) -> Self: ...
|
||||
getpen = getturtle
|
||||
def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ...
|
||||
def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
|
||||
from _typeshed import Self
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from types import CodeType, FrameType, TracebackType
|
||||
|
||||
@@ -462,11 +463,11 @@ class NamedTuple(Tuple[Any, ...]):
|
||||
@classmethod
|
||||
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
|
||||
def _asdict(self) -> Dict[str, Any]: ...
|
||||
def _replace(self: _T, **kwargs: Any) -> _T: ...
|
||||
def _replace(self: Self, **kwargs: Any) -> Self: ...
|
||||
|
||||
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
|
||||
class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
def copy(self: _T) -> _T: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import abc
|
||||
from _typeshed import Self
|
||||
from typing import (
|
||||
TYPE_CHECKING as TYPE_CHECKING,
|
||||
Any,
|
||||
@@ -45,7 +46,7 @@ def IntVar(name: str) -> Any: ... # returns a new TypeVar
|
||||
|
||||
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
|
||||
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
def copy(self: _T) -> _T: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple, TypeVar
|
||||
from _typeshed import Self
|
||||
from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple
|
||||
|
||||
def url2pathname(pathname: AnyStr) -> AnyStr: ...
|
||||
def pathname2url(pathname: AnyStr) -> AnyStr: ...
|
||||
@@ -77,15 +78,13 @@ class ftpwrapper:
|
||||
def file_close(self): ...
|
||||
def real_close(self): ...
|
||||
|
||||
_AIUT = TypeVar("_AIUT", bound=addbase)
|
||||
|
||||
class addbase:
|
||||
fp: Any
|
||||
def read(self, n: int = ...) -> bytes: ...
|
||||
def readline(self, limit: int = ...) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> List[bytes]: ...
|
||||
def fileno(self) -> int: ... # Optional[int], but that is rare
|
||||
def __iter__(self: _AIUT) -> _AIUT: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def next(self) -> bytes: ...
|
||||
def __init__(self, fp) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import xml.dom
|
||||
from typing import IO, Any, Text as _Text, TypeVar
|
||||
from _typeshed import Self
|
||||
from typing import IO, Any, Text as _Text
|
||||
from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS
|
||||
from xml.sax.xmlreader import XMLReader
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def parse(file: str | IO[Any], parser: XMLReader | None = ..., bufsize: int | None = ...): ...
|
||||
def parseString(string: bytes | _Text, parser: XMLReader | None = ...): ...
|
||||
def getDOMImplementation(features=...): ...
|
||||
@@ -32,7 +31,7 @@ class Node(xml.dom.Node):
|
||||
def setUserData(self, key, data, handler): ...
|
||||
childNodes: Any
|
||||
def unlink(self) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, et, ev, tb) -> None: ...
|
||||
|
||||
class DocumentFragment(Node):
|
||||
|
||||
Reference in New Issue
Block a user