diff --git a/mypy/subtypes.py b/mypy/subtypes.py index d9c1b47c317fe..17b818c49c677 100644 --- a/mypy/subtypes.py +++ b/mypy/subtypes.py @@ -1581,7 +1581,6 @@ def get_member_flags(name: str, itype: Instance, class_obj: bool = False) -> set """ info = itype.type method = info.get_method(name) - setattr_meth = info.get_method("__setattr__") if method: if isinstance(method, Decorator): if method.var.is_staticmethod or method.var.is_classmethod: @@ -1592,7 +1591,7 @@ def get_member_flags(name: str, itype: Instance, class_obj: bool = False) -> set assert isinstance(method, OverloadedFuncDef) dec = method.items[0] assert isinstance(dec, Decorator) - if dec.var.is_settable_property or setattr_meth: + if dec.var.is_settable_property or info.get_method("__setattr__"): flags = {IS_VAR, IS_SETTABLE} if dec.var.setter_type is not None: flags.add(IS_EXPLICIT_SETTER) @@ -1602,7 +1601,7 @@ def get_member_flags(name: str, itype: Instance, class_obj: bool = False) -> set return set() # Just a regular method node = info.get(name) if not node: - if setattr_meth: + if info.get_method("__setattr__"): return {IS_SETTABLE} if itype.extra_attrs and name in itype.extra_attrs.attrs: flags = set()