Skip to content

Commit 4fb7bbb

Browse files
committed
Docs
1 parent 29d5ea9 commit 4fb7bbb

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ Helpers
203203
ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=ClassProps.KeywordOnly.NO, collect_by_mro=False, init=True, repr=True, eq=True, order=True, hash=ClassProps.Hashability.UNHASHABLE, match_args=True, str=False, getstate_setstate=False, on_setattr=None, field_transformer=None)
204204

205205
.. autoclass:: attrs.ClassProps
206+
.. autoclass:: attrs.ClassProps.Hashability
207+
:members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE
208+
.. autoclass:: attrs.ClassProps.KeywordOnly
209+
:members: NO, YES, FORCE
206210

207211
.. autofunction:: attrs.resolve_types
208212

src/attr/_props.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,32 @@ class ClassProps(NamedTuple):
2525
class Hashability(enum.Enum):
2626
"""
2727
The hashability of a class.
28+
29+
.. versionadded:: 25.4.0
2830
"""
2931

30-
HASHABLE = "hashable" # write a __hash__
31-
HASHABLE_CACHED = (
32-
"hashable_cache" # write a __hash__ and cache the hash
33-
)
34-
UNHASHABLE = "unhashable" # set __hash__ to None
35-
LEAVE_ALONE = "leave_alone" # don't touch __hash__
32+
HASHABLE = "hashable"
33+
"""Write a ``__hash__``."""
34+
HASHABLE_CACHED = "hashable_cache"
35+
"""Write a ``__hash__`` and cache the hash."""
36+
UNHASHABLE = "unhashable"
37+
"""Set ``__hash__`` to ``None``."""
38+
LEAVE_ALONE = "leave_alone"
39+
"""Don't touch ``__hash__``."""
3640

3741
class KeywordOnly(enum.Enum):
3842
"""
3943
How attributes should be treated regarding keyword-only parameters.
44+
45+
.. versionadded:: 25.4.0
4046
"""
4147

42-
NO = "no" # attributes are not keyword-only
43-
YES = "yes" # attributes in current class without kw_only=False are keyword-only
44-
FORCE = "force" # all attributes are keyword-only
48+
NO = "no"
49+
"""Attributes are not keyword-only."""
50+
YES = "yes"
51+
"""Attributes in current class without kw_only=False are keyword-only."""
52+
FORCE = "force"
53+
"""All attributes are keyword-only."""
4554

4655
is_exception: bool
4756
is_slotted: bool

0 commit comments

Comments
 (0)