Skip to content

Commit 7fae88a

Browse files
committed
Dont's expose has_custom_setattr
1 parent 1e99c0d commit 7fae88a

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
@@ -137,7 +137,6 @@ class ClassProps(NamedTuple):
137137
match_args: bool
138138
str: bool
139139
getstate_setstate: bool
140-
has_custom_setattr: bool
141140
on_setattr: Callable[[str, Any], Any]
142141
field_transformer: Callable[[Attribute], Attribute]
143142

@@ -703,6 +702,7 @@ def __init__(
703702
these,
704703
auto_attribs: bool,
705704
props: ClassProps,
705+
has_custom_setattr: bool,
706706
):
707707
attrs, base_attrs, base_map = _transform_attrs(
708708
cls,
@@ -737,7 +737,7 @@ def __init__(
737737
self._is_exc = props.is_exception
738738
self._on_setattr = props.on_setattr
739739

740-
self._has_custom_setattr = props.has_custom_setattr
740+
self._has_custom_setattr = has_custom_setattr
741741
self._wrote_own_setattr = False
742742

743743
self._cls_dict["__attrs_attrs__"] = self._attrs
@@ -1536,13 +1536,16 @@ def wrap(cls):
15361536
("__getstate__", "__setstate__"),
15371537
default=slots,
15381538
),
1539-
has_custom_setattr=has_own_setattr,
15401539
on_setattr=on_setattr,
15411540
field_transformer=field_transformer,
15421541
)
15431542

15441543
builder = _ClassBuilder(
1545-
cls, these, auto_attribs=auto_attribs, props=props
1544+
cls,
1545+
these,
1546+
auto_attribs=auto_attribs,
1547+
props=props,
1548+
has_custom_setattr=has_own_setattr,
15461549
)
15471550

15481551
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)