Skip to content

Commit 5b4756e

Browse files
committed
Dont's expose has_custom_setattr
1 parent 627e5a3 commit 5b4756e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/attr/_make.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ class ClassProps(NamedTuple):
138138
match_args: bool
139139
str: bool
140140
getstate_setstate: bool
141-
has_custom_setattr: bool
142141
on_setattr: Callable[[str, Any], Any]
143142
field_transformer: Callable[[Attribute], Attribute]
144143

@@ -715,6 +714,7 @@ def __init__(
715714
these,
716715
auto_attribs: bool,
717716
props: ClassProps,
717+
has_custom_setattr: bool,
718718
):
719719
attrs, base_attrs, base_map = _transform_attrs(
720720
cls,
@@ -749,7 +749,7 @@ def __init__(
749749
self._is_exc = props.is_exception
750750
self._on_setattr = props.on_setattr
751751

752-
self._has_custom_setattr = props.has_custom_setattr
752+
self._has_custom_setattr = has_custom_setattr
753753
self._wrote_own_setattr = False
754754

755755
self._cls_dict["__attrs_attrs__"] = self._attrs
@@ -1558,13 +1558,16 @@ def wrap(cls):
15581558
("__getstate__", "__setstate__"),
15591559
default=slots,
15601560
),
1561-
has_custom_setattr=has_own_setattr,
15621561
on_setattr=on_setattr,
15631562
field_transformer=field_transformer,
15641563
)
15651564

15661565
builder = _ClassBuilder(
1567-
cls, these, auto_attribs=auto_attribs, props=props
1566+
cls,
1567+
these,
1568+
auto_attribs=auto_attribs,
1569+
props=props,
1570+
has_custom_setattr=has_own_setattr,
15681571
)
15691572

15701573
if props.repr is True:

tests/test_make.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ class C:
549549
cache_hash=True,
550550
str=True,
551551
getstate_setstate=True,
552-
has_custom_setattr=False,
553552
on_setattr=None,
554553
field_transformer=None,
555554
)
@@ -584,7 +583,6 @@ class CDef:
584583
cache_hash=False,
585584
str=False,
586585
getstate_setstate=False,
587-
has_custom_setattr=False,
588586
on_setattr=None,
589587
field_transformer=None,
590588
)
@@ -2031,10 +2029,10 @@ class C:
20312029
cache_hash=False,
20322030
str=False,
20332031
getstate_setstate=True,
2034-
has_custom_setattr=False,
20352032
on_setattr=None,
20362033
field_transformer=None,
20372034
),
2035+
has_custom_setattr=False,
20382036
)
20392037

20402038
assert "<_ClassBuilder(cls=C)>" == repr(b)
@@ -2068,10 +2066,10 @@ class C:
20682066
cache_hash=False,
20692067
str=False,
20702068
getstate_setstate=True,
2071-
has_custom_setattr=False,
20722069
on_setattr=None,
20732070
field_transformer=None,
20742071
),
2072+
has_custom_setattr=False,
20752073
)
20762074

20772075
cls = (
@@ -2171,10 +2169,10 @@ def our_hasattr(obj, name, /) -> bool:
21712169
cache_hash=False,
21722170
str=False,
21732171
getstate_setstate=True,
2174-
has_custom_setattr=False,
21752172
on_setattr=None,
21762173
field_transformer=None,
21772174
),
2175+
has_custom_setattr=False,
21782176
)
21792177

21802178
def fake_meth(self):

tests/test_next_gen.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ class C:
493493
cache_hash=True,
494494
str=True,
495495
getstate_setstate=False, # because slots=False
496-
has_custom_setattr=False,
497496
on_setattr=None,
498497
field_transformer=None,
499498
)
@@ -527,7 +526,6 @@ class C:
527526
cache_hash=False,
528527
str=False,
529528
getstate_setstate=True,
530-
has_custom_setattr=False,
531529
on_setattr=None,
532530
field_transformer=None,
533531
)

0 commit comments

Comments
 (0)