Skip to content

Commit 835b427

Browse files
authored
Revert "Check __setattr__ when property is not settable (#9196)" (#9474)
This reverts commit 3186281. Co-authored-by: hauntsaninja <>
1 parent fac2cda commit 835b427

File tree

3 files changed

+2
-44
lines changed

3 files changed

+2
-44
lines changed

mypy/checkmember.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,7 @@ def analyze_var(name: str,
553553
return mx.chk.handle_partial_var_type(typ, mx.is_lvalue, var, mx.context)
554554
if mx.is_lvalue and var.is_property and not var.is_settable_property:
555555
# TODO allow setting attributes in subclass (although it is probably an error)
556-
if info.get('__setattr__') is None:
557-
mx.msg.read_only_property(name, itype.type, mx.context)
556+
mx.msg.read_only_property(name, itype.type, mx.context)
558557
if mx.is_lvalue and var.is_classvar:
559558
mx.msg.cant_assign_to_classvar(name, mx.context)
560559
t = get_proper_type(expand_type_by_instance(typ, itype))
@@ -564,8 +563,7 @@ def analyze_var(name: str,
564563
if mx.is_lvalue:
565564
if var.is_property:
566565
if not var.is_settable_property:
567-
if info.get('__setattr__') is None:
568-
mx.msg.read_only_property(name, itype.type, mx.context)
566+
mx.msg.read_only_property(name, itype.type, mx.context)
569567
else:
570568
mx.msg.cant_assign_to_method(mx.context)
571569

mypy/test/testcheck.py

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
'check-reports.test',
9191
'check-errorcodes.test',
9292
'check-annotated.test',
93-
'check-setattr.test',
9493
'check-parameter-specification.test',
9594
]
9695

test-data/unit/check-setattr.test

-39
This file was deleted.

0 commit comments

Comments
 (0)