28
28
Attribute ,
29
29
ClassProps ,
30
30
Factory ,
31
+ Hashability ,
32
+ KeywordOnly ,
31
33
_AndValidator ,
32
34
_Attributes ,
33
35
_ClassBuilder ,
34
36
_CountingAttr ,
35
37
_determine_attrib_eq_order ,
36
38
_determine_attrs_eq_order ,
37
39
_determine_whether_to_implement ,
38
- _Hashability ,
39
40
_transform_attrs ,
40
41
and_ ,
41
42
fields ,
@@ -183,7 +184,7 @@ def test_no_modifications(self):
183
184
Does not attach __attrs_attrs__ to the class.
184
185
"""
185
186
C = make_tc ()
186
- _transform_attrs (C , None , False , False , False , True , None )
187
+ _transform_attrs (C , None , False , KeywordOnly . NO , True , None )
187
188
188
189
assert None is getattr (C , "__attrs_attrs__" , None )
189
190
@@ -193,7 +194,7 @@ def test_normal(self):
193
194
"""
194
195
C = make_tc ()
195
196
attrs , _ , _ = _transform_attrs (
196
- C , None , False , False , False , True , None
197
+ C , None , False , KeywordOnly . NO , True , None
197
198
)
198
199
199
200
assert ["z" , "y" , "x" ] == [a .name for a in attrs ]
@@ -208,7 +209,7 @@ class C:
208
209
pass
209
210
210
211
assert _Attributes ((), [], {}) == _transform_attrs (
211
- C , None , False , False , False , True , None
212
+ C , None , False , KeywordOnly . NO , True , None
212
213
)
213
214
214
215
def test_transforms_to_attribute (self ):
@@ -217,7 +218,7 @@ def test_transforms_to_attribute(self):
217
218
"""
218
219
C = make_tc ()
219
220
attrs , base_attrs , _ = _transform_attrs (
220
- C , None , False , False , False , True , None
221
+ C , None , False , KeywordOnly . NO , True , None
221
222
)
222
223
223
224
assert [] == base_attrs
@@ -235,7 +236,7 @@ class C:
235
236
y = attr .ib ()
236
237
237
238
with pytest .raises (ValueError ) as e :
238
- _transform_attrs (C , None , False , False , False , True , None )
239
+ _transform_attrs (C , None , False , KeywordOnly . NO , True , None )
239
240
assert (
240
241
"No mandatory attributes allowed after an attribute with a "
241
242
"default value or factory. Attribute in question: Attribute"
@@ -264,7 +265,7 @@ class C(B):
264
265
y = attr .ib ()
265
266
266
267
attrs , base_attrs , _ = _transform_attrs (
267
- C , None , False , True , False , True , None
268
+ C , None , False , KeywordOnly . YES , True , None
268
269
)
269
270
270
271
assert len (attrs ) == 3
@@ -280,8 +281,7 @@ class C(B):
280
281
C ,
281
282
None ,
282
283
False ,
283
- True ,
284
- True , # force kw-only
284
+ KeywordOnly .FORCE ,
285
285
True ,
286
286
None ,
287
287
)
@@ -307,7 +307,7 @@ class C(Base):
307
307
y = attr .ib ()
308
308
309
309
attrs , base_attrs , _ = _transform_attrs (
310
- C , {"x" : attr .ib ()}, False , False , False , True , None
310
+ C , {"x" : attr .ib ()}, False , KeywordOnly . NO , True , None
311
311
)
312
312
313
313
assert [] == base_attrs
@@ -540,10 +540,9 @@ class C:
540
540
repr = True ,
541
541
eq = True ,
542
542
order = True ,
543
- hash = _Hashability .HASHABLE ,
543
+ hash = Hashability .HASHABLE ,
544
544
match_args = False ,
545
- is_kw_only = True ,
546
- force_kw_only = True ,
545
+ kw_only = KeywordOnly .FORCE ,
547
546
has_weakref_slot = True ,
548
547
collect_by_mro = False ,
549
548
cache_hash = True ,
@@ -574,10 +573,9 @@ class CDef:
574
573
repr = True ,
575
574
eq = True ,
576
575
order = True ,
577
- hash = _Hashability .UNHASHABLE ,
576
+ hash = Hashability .UNHASHABLE ,
578
577
match_args = True ,
579
- is_kw_only = False ,
580
- force_kw_only = True ,
578
+ kw_only = KeywordOnly .NO ,
581
579
has_weakref_slot = True ,
582
580
collect_by_mro = False ,
583
581
cache_hash = False ,
@@ -2022,8 +2020,7 @@ class C:
2022
2020
order = False ,
2023
2021
hash = False ,
2024
2022
match_args = True ,
2025
- is_kw_only = False ,
2026
- force_kw_only = False ,
2023
+ kw_only = KeywordOnly .NO ,
2027
2024
has_weakref_slot = False ,
2028
2025
collect_by_mro = True ,
2029
2026
cache_hash = False ,
@@ -2059,8 +2056,7 @@ class C:
2059
2056
order = False ,
2060
2057
hash = False ,
2061
2058
match_args = True ,
2062
- is_kw_only = False ,
2063
- force_kw_only = False ,
2059
+ kw_only = KeywordOnly .NO ,
2064
2060
has_weakref_slot = False ,
2065
2061
collect_by_mro = True ,
2066
2062
cache_hash = False ,
@@ -2162,8 +2158,7 @@ def our_hasattr(obj, name, /) -> bool:
2162
2158
order = False ,
2163
2159
hash = False ,
2164
2160
match_args = True ,
2165
- is_kw_only = False ,
2166
- force_kw_only = False ,
2161
+ kw_only = KeywordOnly .NO ,
2167
2162
has_weakref_slot = True ,
2168
2163
collect_by_mro = True ,
2169
2164
cache_hash = False ,
0 commit comments