fractions: use __new__ instead of __init__ (#4077)

Tested against some example code.
This commit is contained in:
Shantanu
2020-05-25 15:29:28 -07:00
committed by GitHub
parent 6028226750
commit 6aee098401
2 changed files with 7 additions and 10 deletions

View File

@@ -25,17 +25,13 @@ if sys.version_info < (3, 9):
class Fraction(Rational):
@overload
def __init__(self,
numerator: Union[int, Rational] = ...,
denominator: Optional[Union[int, Rational]] = ...,
*,
_normalize: bool = ...) -> None: ...
def __new__(cls,
numerator: Union[int, Rational] = ...,
denominator: Optional[Union[int, Rational]] = ...,
*,
_normalize: bool = ...) -> Fraction: ...
@overload
def __init__(self, value: float, *, _normalize: bool = ...) -> None: ...
@overload
def __init__(self, value: Decimal, *, _normalize: bool = ...) -> None: ...
@overload
def __init__(self, value: str, *, _normalize: bool = ...) -> None: ...
def __new__(cls, __value: Union[float, Decimal, str], *, _normalize: bool = ...) -> Fraction: ...
@classmethod
def from_float(cls, f: float) -> Fraction: ...

View File

@@ -23,6 +23,7 @@ collections.Reversible
collections.UserString.maketrans
ctypes.CDLL.__init__
decimal.Decimal.as_integer_ratio
fractions.Fraction.__new__ # private _normalize param was made keyword-only in Python 3.6
gettext.NullTranslations.npgettext
gettext.NullTranslations.pgettext
gettext.dnpgettext