File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1459,7 +1459,7 @@ def __round__(self, /) -> _T_int_co: ...
14591459
14601460@runtime_checkable
14611461class CanRound2 (Protocol [_T_int_contra , _T_float_co ]):
1462- def __round__ (self , / , ndigits : _T_int_contra ) -> _T_float_co : ...
1462+ def __round__ (self , ndigits : _T_int_contra , / ) -> _T_float_co : ...
14631463
14641464
14651465@runtime_checkable
@@ -1472,7 +1472,7 @@ class CanRound(
14721472 @override
14731473 def __round__ (self , / ) -> _T_int_co : ...
14741474 @overload
1475- def __round__ (self , / , ndigits : _T_int_contra ) -> _T_float_co : ...
1475+ def __round__ (self , ndigits : _T_int_contra , / ) -> _T_float_co : ...
14761476
14771477
14781478@runtime_checkable
Original file line number Diff line number Diff line change @@ -352,3 +352,18 @@ def test_can_same_self(cls: type) -> None:
352352
353353 assert members_same == members_self
354354 assert members_same == members_base
355+
356+
357+ def test_can_round_float () -> None :
358+ # https://github.com/jorenham/optype/issues/596
359+
360+ x : float = 1 / 137
361+
362+ r1 : op .CanRound1 [int ] = x
363+ assert isinstance (r1 , op .CanRound1 )
364+
365+ r2 : op .CanRound2 [int , float ] = x
366+ assert isinstance (r2 , op .CanRound2 )
367+
368+ r : op .CanRound [int , int , float ] = x
369+ assert isinstance (r , op .CanRound )
You can’t perform that action at this time.
0 commit comments