mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Fix some issues with __round__ (#2907)
In python 3, add an overload for there being no digits argument and make it return int. In python 2, __round__ doesn't exist and SupportsRound doesn't exist in the typing module. Use SupportsFloat for python 2 round(). Remove decimal's __round__ overload that takes None, since it doesn't exist
This commit is contained in:
committed by
GitHub
parent
50a661afed
commit
0350e9fa89
@@ -95,8 +95,12 @@ class SupportsAbs(Protocol[_T_co]):
|
||||
|
||||
@runtime
|
||||
class SupportsRound(Protocol[_T_co]):
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __round__(self, ndigits: int = ...) -> _T_co: ...
|
||||
def __round__(self) -> int: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __round__(self, ndigits: int) -> _T_co: ...
|
||||
|
||||
@runtime
|
||||
class Reversible(Protocol[_T_co]):
|
||||
|
||||
Reference in New Issue
Block a user