mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable * Revert changes to `google-cloud-ndb` (ambiguous) * Remove empty line added by script * Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi` * Manually add a few more that the script missed * Improve `filelock` annotation Source code here:79ec7b2826/src/filelock/_api.py (L207)* Improve `opentracing/scope` annotation Source code here:3e1d357a34/opentracing/scope.py (L71)* Improve `redis/client` stub Source code here:15f315a496/redis/client.py (L1217)* Improve `redis/lock` annotation Source code here:15f315a496/redis/lock.py (L155)* Improve `requests/models` annotation Source code here:d718e75383/requests/models.py (L653)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
|
||||
import sys
|
||||
from _typeshed import SupportsKeysAndGetItem
|
||||
from _typeshed import Self, SupportsKeysAndGetItem
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
|
||||
from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec, final as _final
|
||||
@@ -702,11 +702,11 @@ class NamedTuple(Tuple[Any, ...]):
|
||||
def _asdict(self) -> dict[str, Any]: ...
|
||||
else:
|
||||
def _asdict(self) -> collections.OrderedDict[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: ...
|
||||
@@ -717,8 +717,8 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
def items(self) -> ItemsView[str, object]: ...
|
||||
def keys(self) -> KeysView[str]: ...
|
||||
def values(self) -> ValuesView[object]: ...
|
||||
def __or__(self: _T, __value: _T) -> _T: ...
|
||||
def __ior__(self: _T, __value: _T) -> _T: ...
|
||||
def __or__(self: Self, __value: Self) -> Self: ...
|
||||
def __ior__(self: Self, __value: Self) -> Self: ...
|
||||
|
||||
# This itself is only available during type checking
|
||||
def type_check_only(func_or_cls: _F) -> _F: ...
|
||||
|
||||
Reference in New Issue
Block a user