Skip to content

Commit 834e125

Browse files
committed
feat: check if @property overrides parent class variable
1 parent 6badb4a commit 834e125

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mypy/checker.py

+11
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,17 @@ def check_method_override_for_base_with_name(
22802280
if inner is not None:
22812281
typ = inner
22822282
typ = get_property_type(typ)
2283+
2284+
if (
2285+
isinstance(original_node, Var)
2286+
and original_node.is_classvar
2287+
and defn.name == original_node.name
2288+
and isinstance(defn, Decorator)
2289+
):
2290+
self.fail(
2291+
message_registry.CANNOT_OVERRIDE_CLASS_VAR.format(base.name), defn.func
2292+
)
2293+
22832294
if (
22842295
isinstance(original_node, Var)
22852296
and not original_node.is_final

0 commit comments

Comments
 (0)