11import sys
22from decimal import Decimal
33from numbers import Integral , Rational , Real
4- from typing import Optional , Tuple , Union , overload
4+ from typing import Optional , Tuple , Type , TypeVar , Union , overload
55from typing_extensions import Literal
66
77_ComparableNum = Union [int , float , Decimal , Real ]
8+ _T = TypeVar ("_T" )
89
910if sys .version_info < (3 , 9 ):
1011 @overload
@@ -19,10 +20,14 @@ if sys.version_info < (3, 9):
1920class Fraction (Rational ):
2021 @overload
2122 def __new__ (
22- cls , numerator : Union [int , Rational ] = ..., denominator : Optional [Union [int , Rational ]] = ..., * , _normalize : bool = ...
23- ) -> Fraction : ...
24- @overload
25- def __new__ (cls , __value : Union [float , Decimal , str ], * , _normalize : bool = ...) -> Fraction : ...
23+ cls : Type [_T ],
24+ numerator : Union [int , Rational ] = ...,
25+ denominator : Optional [Union [int , Rational ]] = ...,
26+ * ,
27+ _normalize : bool = ...,
28+ ) -> _T : ...
29+ @overload
30+ def __new__ (cls : Type [_T ], __value : Union [float , Decimal , str ], * , _normalize : bool = ...) -> _T : ...
2631 @classmethod
2732 def from_float (cls , f : float ) -> Fraction : ...
2833 @classmethod
0 commit comments