mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
More improvements to pow stubs (#7737)
This commit is contained in:
@@ -254,7 +254,9 @@ class int:
|
||||
@overload
|
||||
def __pow__(self, __x: int, __modulo: int) -> int: ...
|
||||
@overload
|
||||
def __pow__(self, __x: Literal[0], __modulo: None = ...) -> Literal[1]: ...
|
||||
def __pow__(self, __x: Literal[0]) -> Literal[1]: ...
|
||||
@overload
|
||||
def __pow__(self, __x: Literal[0], __modulo: None) -> Literal[1]: ...
|
||||
@overload
|
||||
def __pow__(self, __x: _PositiveInteger, __modulo: None = ...) -> int: ...
|
||||
@overload
|
||||
@@ -327,7 +329,12 @@ class float:
|
||||
def __rtruediv__(self, __x: float) -> float: ...
|
||||
def __rmod__(self, __x: float) -> float: ...
|
||||
def __rdivmod__(self, __x: float) -> tuple[float, float]: ...
|
||||
# Returns complex if the argument is negative.
|
||||
@overload
|
||||
def __rpow__(self, __x: _PositiveInteger, __modulo: None = ...) -> float: ...
|
||||
@overload
|
||||
def __rpow__(self, __x: _NegativeInteger, __mod: None = ...) -> complex: ...
|
||||
# Returning `complex` for the general case gives too many false-positive errors.
|
||||
@overload
|
||||
def __rpow__(self, __x: float, __mod: None = ...) -> Any: ...
|
||||
def __getnewargs__(self) -> tuple[float]: ...
|
||||
def __trunc__(self) -> int: ...
|
||||
@@ -1422,6 +1429,10 @@ if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def pow(base: int, exp: int, mod: None = ...) -> Any: ...
|
||||
@overload
|
||||
def pow(base: _PositiveInteger, exp: float, mod: None = ...) -> float: ...
|
||||
@overload
|
||||
def pow(base: _NegativeInteger, exp: float, mod: None = ...) -> complex: ...
|
||||
@overload
|
||||
def pow(base: float, exp: int, mod: None = ...) -> float: ...
|
||||
# float base & float exp could return float or complex
|
||||
# return type must be Any (same as complex base, complex exp),
|
||||
@@ -1455,6 +1466,10 @@ else:
|
||||
@overload
|
||||
def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ...
|
||||
@overload
|
||||
def pow(__base: _PositiveInteger, __exp: float, __mod: None = ...) -> float: ...
|
||||
@overload
|
||||
def pow(__base: _NegativeInteger, __exp: float, __mod: None = ...) -> complex: ...
|
||||
@overload
|
||||
def pow(__base: float, __exp: int, __mod: None = ...) -> float: ...
|
||||
@overload
|
||||
def pow(__base: float, __exp: complex | _SupportsSomeKindOfPow, __mod: None = ...) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user