mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Various stdlib dunders: correct parameter names; improve types; add defaults (#9761)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
@@ -89,7 +89,7 @@ class Decimal:
|
||||
def __mul__(self, __other: _Decimal) -> Decimal: ...
|
||||
def __neg__(self) -> Decimal: ...
|
||||
def __pos__(self) -> Decimal: ...
|
||||
def __pow__(self, __other: _Decimal, __modulo: _Decimal | None = ...) -> Decimal: ...
|
||||
def __pow__(self, __value: _Decimal, __mod: _Decimal | None = None) -> Decimal: ...
|
||||
def __radd__(self, __other: _Decimal) -> Decimal: ...
|
||||
def __rdivmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ...
|
||||
def __rfloordiv__(self, __other: _Decimal) -> Decimal: ...
|
||||
@@ -116,7 +116,7 @@ class Decimal:
|
||||
def __floor__(self) -> int: ...
|
||||
def __ceil__(self) -> int: ...
|
||||
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||
def __rpow__(self, __other: _Decimal, __context: Context | None = ...) -> Decimal: ...
|
||||
def __rpow__(self, __value: _Decimal, __mod: Context | None = None) -> Decimal: ...
|
||||
def normalize(self, context: Context | None = None) -> Decimal: ...
|
||||
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
|
||||
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
|
||||
|
||||
@@ -117,7 +117,7 @@ class staticmethod(Generic[_R_co]):
|
||||
@property
|
||||
def __isabstractmethod__(self) -> bool: ...
|
||||
def __init__(self: staticmethod[_R_co], __f: Callable[..., _R_co]) -> None: ...
|
||||
def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R_co]: ...
|
||||
def __get__(self, __instance: _T, __owner: type[_T] | None = None) -> Callable[..., _R_co]: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
@@ -131,7 +131,7 @@ class classmethod(Generic[_R_co]):
|
||||
@property
|
||||
def __isabstractmethod__(self) -> bool: ...
|
||||
def __init__(self: classmethod[_R_co], __f: Callable[..., _R_co]) -> None: ...
|
||||
def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R_co]: ...
|
||||
def __get__(self, __instance: _T, __owner: type[_T] | None = None) -> Callable[..., _R_co]: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
@@ -958,7 +958,7 @@ class function:
|
||||
|
||||
__module__: str
|
||||
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
|
||||
def __get__(self, obj: object, type: type | None = ...) -> Any: ...
|
||||
def __get__(self, __instance: object, __owner: type | None = None) -> Any: ...
|
||||
|
||||
class list(MutableSequence[_T], Generic[_T]):
|
||||
@overload
|
||||
@@ -1185,9 +1185,9 @@ class property:
|
||||
def getter(self, __fget: Callable[[Any], Any]) -> property: ...
|
||||
def setter(self, __fset: Callable[[Any, Any], None]) -> property: ...
|
||||
def deleter(self, __fdel: Callable[[Any], None]) -> property: ...
|
||||
def __get__(self, __obj: Any, __type: type | None = ...) -> Any: ...
|
||||
def __set__(self, __obj: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, __obj: Any) -> None: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
def __set__(self, __instance: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, __instance: Any) -> None: ...
|
||||
|
||||
@final
|
||||
class _NotImplementedType(Any): # type: ignore[misc]
|
||||
|
||||
@@ -110,7 +110,7 @@ if sys.platform == "linux":
|
||||
def __exit__(
|
||||
self,
|
||||
__exc_type: type[BaseException] | None = None,
|
||||
__exc_val: BaseException | None = ...,
|
||||
__exc_value: BaseException | None = ...,
|
||||
__exc_tb: TracebackType | None = None,
|
||||
) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
@@ -103,9 +103,9 @@ class FunctionType:
|
||||
) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
@overload
|
||||
def __get__(self, obj: None, type: type) -> FunctionType: ...
|
||||
def __get__(self, __instance: None, __owner: type) -> FunctionType: ...
|
||||
@overload
|
||||
def __get__(self, obj: object, type: type | None = ...) -> MethodType: ...
|
||||
def __get__(self, __instance: object, __owner: type | None = None) -> MethodType: ...
|
||||
|
||||
LambdaType = FunctionType
|
||||
|
||||
@@ -454,7 +454,7 @@ class WrapperDescriptorType:
|
||||
@property
|
||||
def __objclass__(self) -> type: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
|
||||
@final
|
||||
class MethodWrapperType:
|
||||
@@ -479,7 +479,7 @@ class MethodDescriptorType:
|
||||
@property
|
||||
def __objclass__(self) -> type: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
|
||||
@final
|
||||
class ClassMethodDescriptorType:
|
||||
@@ -490,7 +490,7 @@ class ClassMethodDescriptorType:
|
||||
@property
|
||||
def __objclass__(self) -> type: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
|
||||
@final
|
||||
class TracebackType:
|
||||
@@ -536,7 +536,7 @@ class GetSetDescriptorType:
|
||||
def __qualname__(self) -> str: ...
|
||||
@property
|
||||
def __objclass__(self) -> type: ...
|
||||
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
def __set__(self, __instance: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, __obj: Any) -> None: ...
|
||||
|
||||
@@ -548,7 +548,7 @@ class MemberDescriptorType:
|
||||
def __qualname__(self) -> str: ...
|
||||
@property
|
||||
def __objclass__(self) -> type: ...
|
||||
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
|
||||
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
|
||||
def __set__(self, __instance: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, __obj: Any) -> None: ...
|
||||
|
||||
|
||||
@@ -157,6 +157,11 @@ builtins.property.__get__
|
||||
builtins.staticmethod.__get__
|
||||
types.FunctionType.__get__
|
||||
types.LambdaType.__get__
|
||||
types.ClassMethodDescriptorType.__get__
|
||||
types.GetSetDescriptorType.__get__
|
||||
types.MemberDescriptorType.__get__
|
||||
types.MethodDescriptorType.__get__
|
||||
types.WrapperDescriptorType.__get__
|
||||
|
||||
# Missing from distutils (deprecated, to be removed in 3.12)
|
||||
distutils.core.USAGE
|
||||
|
||||
@@ -174,6 +174,11 @@ builtins.property.__get__
|
||||
builtins.staticmethod.__get__
|
||||
types.FunctionType.__get__
|
||||
types.LambdaType.__get__
|
||||
types.ClassMethodDescriptorType.__get__
|
||||
types.GetSetDescriptorType.__get__
|
||||
types.MemberDescriptorType.__get__
|
||||
types.MethodDescriptorType.__get__
|
||||
types.WrapperDescriptorType.__get__
|
||||
|
||||
# Missing from distutils (deprecated, to be removed in 3.12)
|
||||
distutils.core.USAGE
|
||||
|
||||
@@ -169,6 +169,11 @@ builtins.property.__get__
|
||||
builtins.staticmethod.__get__
|
||||
types.FunctionType.__get__
|
||||
types.LambdaType.__get__
|
||||
types.ClassMethodDescriptorType.__get__
|
||||
types.GetSetDescriptorType.__get__
|
||||
types.MemberDescriptorType.__get__
|
||||
types.MethodDescriptorType.__get__
|
||||
types.WrapperDescriptorType.__get__
|
||||
|
||||
# Missing from distutils (deprecated, to be removed in 3.12)
|
||||
distutils.core.USAGE
|
||||
|
||||
@@ -428,13 +428,6 @@ pickle.Unpickler.memo # undocumented implementation detail, has different type
|
||||
re.Pattern.scanner # Undocumented and not useful. #6405
|
||||
tempfile._TemporaryFileWrapper.[\w_]+ # Dynamically specified by __getattr__, and thus don't exist on the class
|
||||
|
||||
# Runtime signature is incorrect (https://github.com/python/cpython/issues/93021)
|
||||
types.ClassMethodDescriptorType.__get__
|
||||
types.GetSetDescriptorType.__get__
|
||||
types.MemberDescriptorType.__get__
|
||||
types.MethodDescriptorType.__get__
|
||||
types.WrapperDescriptorType.__get__
|
||||
|
||||
# Various classes in typing aren't types at runtime. In addition, mypy thinks some special forms are tautologically defined.
|
||||
typing.[A-Z]\w+
|
||||
typing_extensions\..*
|
||||
|
||||
Reference in New Issue
Block a user