You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-final.test
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -301,6 +301,37 @@ class P(Protocol):
301
301
pass
302
302
[out]
303
303
304
+
[case testFinalInProtocol]
305
+
from typing import Protocol, Final, final, ClassVar
306
+
307
+
class P(Protocol):
308
+
var1 : Final[int] = 0 # E: Protocol member cannot be final
309
+
310
+
@final # E: Protocol member cannot be final
311
+
def meth1(self) -> None:
312
+
var2: Final = 0
313
+
314
+
def meth2(self) -> None:
315
+
var3: Final = 0
316
+
317
+
[out]
318
+
319
+
[case testFinalWithClassVarInProtocol]
320
+
from typing import Protocol, Final, final, ClassVar
321
+
322
+
class P(Protocol):
323
+
var1 : Final[ClassVar[int]] = 0 # E: Variable should not be annotated with both ClassVar and Final
324
+
var2: ClassVar[int] = 1
325
+
326
+
@final # E: Protocol member cannot be final
327
+
def meth1(self) -> None:
328
+
...
329
+
330
+
def meth2(self) -> None:
331
+
var3: Final[ClassVar[int]] = 0 # E: Variable should not be annotated with both ClassVar and Final # E: ClassVar can only be used for assignments in class body
0 commit comments