Skip to content

Commit

Permalink
Fix "Fraction.__int__" magic method
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed Nov 14, 2024
1 parent 2b78f6f commit 94c212b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cfractions/_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,15 @@ def __gt__(self, other: _Any, /) -> _Any:
def __hash__(self, /) -> int:
return hash(self._value)

def __int__(self, /) -> int:
return self._value.__int__()
if sys.version_info >= (3, 11):

def __int__(self, /) -> int:
return self._value.__int__()

else:

def __int__(self, /) -> int:
return self.__trunc__()

@_overload
def __le__(self, other: _Rational | Self, /) -> bool: ...
Expand Down

0 comments on commit 94c212b

Please sign in to comment.