Skip to content

Commit 4b1d869

Browse files
committed
Simplify slot field detection
1 parent deb9763 commit 4b1d869

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/attr/_make.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -2113,15 +2113,12 @@ def validate(inst):
21132113
v(inst, a, getattr(inst, a.name))
21142114

21152115

2116-
def _is_slot_cls(cls):
2117-
return "__slots__" in cls.__dict__
2118-
2119-
21202116
def _is_slot_attr(a_name, base_attr_map):
21212117
"""
21222118
Check if the attribute name comes from a slot class.
21232119
"""
2124-
return a_name in base_attr_map and _is_slot_cls(base_attr_map[a_name])
2120+
cls = base_attr_map.get(a_name)
2121+
return cls and "__slots__" in cls.__dict__
21252122

21262123

21272124
def _make_init(

tests/test_dunders.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
NOTHING,
2121
Factory,
2222
_add_repr,
23-
_is_slot_cls,
2423
_make_init,
2524
fields,
2625
make_class,
@@ -98,7 +97,7 @@ def _add_init(cls, frozen):
9897
),
9998
getattr(cls, "__attrs_post_init__", False),
10099
frozen,
101-
_is_slot_cls(cls),
100+
"__slots__" in cls.__dict__,
102101
cache_hash=False,
103102
base_attr_map={},
104103
is_exc=False,

0 commit comments

Comments
 (0)