File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -937,3 +937,31 @@ def test_errors() -> None:
937937 pow(ForwardNotImplemented(), Child(), 3) # type: ignore
938938 with assertRaises(TypeError, "unsupported operand type(s) for ** or pow(): 'ForwardModRequired' and 'int'"):
939939 ForwardModRequired()**3 # type: ignore
940+
941+ [case testDundersWithFinal]
942+ from typing import final
943+ class A:
944+ def __init__(self, x: int) -> None:
945+ self.x = x
946+
947+ def __add__(self, y: int) -> int:
948+ return self.x + y
949+
950+ def __lt__(self, x: 'A') -> bool:
951+ return self.x < x.x
952+
953+ @final
954+ class B(A):
955+ def __add__(self, y: int) -> int:
956+ return self.x + y + 1
957+
958+ def __lt__(self, x: 'A') -> bool:
959+ return self.x < x.x + 1
960+
961+ def test_final() -> None:
962+ a = A(5)
963+ b = B(5)
964+ assert a + 3 == 8
965+ assert b + 3 == 9
966+ assert (a < A(5)) is False
967+ assert (a < A(5)) is True
You can’t perform that action at this time.
0 commit comments