mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
Use typing_extensions.Self in the stdlib (#9694)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Callable
|
||||
from decimal import Decimal
|
||||
from numbers import Integral, Rational, Real
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias
|
||||
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias
|
||||
|
||||
_ComparableNum: TypeAlias = int | float | Decimal | Real
|
||||
|
||||
@@ -24,14 +23,14 @@ else:
|
||||
class Fraction(Rational):
|
||||
@overload
|
||||
def __new__(
|
||||
cls: type[Self], numerator: int | Rational = 0, denominator: int | Rational | None = None, *, _normalize: bool = True
|
||||
cls, numerator: int | Rational = 0, denominator: int | Rational | None = None, *, _normalize: bool = True
|
||||
) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[Self], __value: float | Decimal | str, *, _normalize: bool = True) -> Self: ...
|
||||
def __new__(cls, __value: float | Decimal | str, *, _normalize: bool = True) -> Self: ...
|
||||
@classmethod
|
||||
def from_float(cls: type[Self], f: float) -> Self: ...
|
||||
def from_float(cls, f: float) -> Self: ...
|
||||
@classmethod
|
||||
def from_decimal(cls: type[Self], dec: Decimal) -> Self: ...
|
||||
def from_decimal(cls, dec: Decimal) -> Self: ...
|
||||
def limit_denominator(self, max_denominator: int = 1000000) -> Fraction: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def as_integer_ratio(self) -> tuple[int, int]: ...
|
||||
@@ -139,8 +138,8 @@ class Fraction(Rational):
|
||||
def __le__(a, b: _ComparableNum) -> bool: ...
|
||||
def __ge__(a, b: _ComparableNum) -> bool: ...
|
||||
def __bool__(a) -> bool: ...
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
def __deepcopy__(self: Self, memo: Any) -> Self: ...
|
||||
def __copy__(self) -> Self: ...
|
||||
def __deepcopy__(self, memo: Any) -> Self: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __int__(a, _index: Callable[[SupportsIndex], int] = ...) -> int: ...
|
||||
# Not actually defined within fractions.py, but provides more useful
|
||||
|
||||
Reference in New Issue
Block a user