@@ -2,7 +2,7 @@ import sys
22from collections .abc import Callable
33from decimal import Decimal
44from numbers import Integral , Rational , Real
5- from typing import Any , Literal , SupportsIndex , overload
5+ from typing import Any , Literal , Protocol , SupportsIndex , overload
66from typing_extensions import Self , TypeAlias
77
88_ComparableNum : TypeAlias = int | float | Decimal | Real
@@ -20,11 +20,19 @@ else:
2020 @overload
2121 def gcd (a : Integral , b : Integral ) -> Integral : ...
2222
23+ class _ConvertibleToIntegerRatio (Protocol ):
24+ def as_integer_ratio (self ) -> tuple [int | Rational , int | Rational ]: ...
25+
2326class Fraction (Rational ):
2427 @overload
2528 def __new__ (cls , numerator : int | Rational = 0 , denominator : int | Rational | None = None ) -> Self : ...
2629 @overload
2730 def __new__ (cls , value : float | Decimal | str , / ) -> Self : ...
31+
32+ if sys .version_info >= (3 , 14 ):
33+ @overload
34+ def __new__ (cls , value : _ConvertibleToIntegerRatio ) -> Self : ...
35+
2836 @classmethod
2937 def from_float (cls , f : float ) -> Self : ...
3038 @classmethod
0 commit comments