Skip to content

Commit 4a41e4e

Browse files
committed
Use python 3.12 and 3.13 flag, Final can be inside ClassVar after py 3.13
1 parent 6c4d78b commit 4a41e4e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

mypy/typeanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Typ
605605
t,
606606
code=codes.VALID_TYPE,
607607
)
608-
else:
608+
elif self.options.python_version < (3, 13):
609609
self.fail(
610610
"Final can be only used as an outermost qualifier in a variable annotation",
611611
t,

test-data/unit/check-final.test

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,13 +1128,23 @@ class A:
11281128
[builtins fixtures/tuple.pyi]
11291129

11301130
[case testFinalUsedWithClassVar]
1131+
# flags: --python-version 3.12
11311132
from typing import Final, ClassVar
11321133

11331134
class A:
11341135
a: Final[ClassVar[int]] # E: Variable should not be annotated with both ClassVar and Final
11351136
b: ClassVar[Final[int]] # E: Final can be only used as an outermost qualifier in a variable annotation
11361137
c: ClassVar[Final] = 1 # E: Final can be only used as an outermost qualifier in a variable annotation
1137-
[out version<3.13]
1138+
[out]
1139+
1140+
[case testFinalUsedWithClassVarAfterPy313]
1141+
# flags: --python-version 3.13
1142+
from typing import Final, ClassVar
1143+
1144+
class A:
1145+
a: Final[ClassVar[int]] = 1
1146+
b: ClassVar[Final[int]] = 1
1147+
c: ClassVar[Final] = 1
11381148

11391149
[case testFinalClassWithAbstractMethod]
11401150
from typing import final

0 commit comments

Comments
 (0)