Skip to content

Commit c770cfd

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

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

mypy/typeanal.py

-6
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,6 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Typ
605605
t,
606606
code=codes.VALID_TYPE,
607607
)
608-
else:
609-
self.fail(
610-
"Final can be only used as an outermost qualifier in a variable annotation",
611-
t,
612-
code=codes.VALID_TYPE,
613-
)
614608
return AnyType(TypeOfAny.from_error)
615609
elif fullname == "typing.Tuple" or (
616610
fullname == "builtins.tuple"

test-data/unit/check-final.test

+11-1
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]]
1146+
b: ClassVar[Final[int]]
1147+
c: ClassVar[Final] = 1
11381148

11391149
[case testFinalClassWithAbstractMethod]
11401150
from typing import final

0 commit comments

Comments
 (0)