Skip to content

Commit 518bf6b

Browse files
committed
Add type information to docs
1 parent 353e39b commit 518bf6b

2 files changed

Lines changed: 29 additions & 19 deletions

File tree

src/attr/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class ClassProps:
166166
match_args: bool
167167
str: bool
168168
getstate_setstate: bool
169-
on_setattr: _OnSetAttrType
170-
field_transformer: Callable[[Attribute[Any]], Attribute[Any]]
169+
on_setattr: _OnSetAttrType | None
170+
field_transformer: Callable[[Attribute[Any]], Attribute[Any]] | None
171171

172172
def __init__(
173173
self,

src/attr/_make.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,42 +2802,52 @@ class ClassProps:
28022802
`define()` decorators.
28032803
28042804
Attributes:
2805-
is_exception: Whether the class is treated as an exception class.
2805+
is_exception (bool):
2806+
Whether the class is treated as an exception class.
28062807
2807-
is_slotted: Whether the class is `slotted <slotted classes>`.
2808+
is_slotted (bool):
2809+
Whether the class is `slotted <slotted classes>`.
28082810
2809-
has_weakref_slot: Whether the class has a weakref slot.
2811+
has_weakref_slot (bool):
2812+
Whether the class has a slot for weak references.
28102813
2811-
is_frozen: Whether the class is frozen.
2814+
is_frozen (bool):
2815+
Whether the class is frozen.
28122816
2813-
kw_only: Whether the class is keyword-only.
2817+
kw_only (KeywordOnly):
2818+
Whether the class is keyword-only.
28142819
2815-
collect_by_mro:
2820+
collect_by_mro (bool):
28162821
Whether the class fields are collected by the method resolution
28172822
order (that is, correctly but unlike `dataclasses`).
28182823
2819-
init: Whether the class has an *attrs*-generated ``__init__`` method.
2824+
init (bool):
2825+
Whether the class has an *attrs*-generated ``__init__`` method.
28202826
2821-
repr: Whether the class has an *attrs*-generated ``__repr__`` method.
2827+
repr (bool):
2828+
Whether the class has an *attrs*-generated ``__repr__`` method.
28222829
2823-
eq: Whether the class has an *attrs*-generated equality methods.
2830+
eq (bool): Whether the class has an *attrs*-generated equality methods.
28242831
2825-
order: Whether the class has an *attrs*-generated ordering methods.
2832+
order (bool):
2833+
Whether the class has an *attrs*-generated ordering methods.
28262834
2827-
hash: How `hashable <hashing>` the class is.
2835+
hash (Hashability): How `hashable <hashing>` the class is.
28282836
2829-
match_args: Whether the class supports `match` over its fields.
2837+
match_args (bool): Whether the class supports `match` over its fields.
28302838
2831-
str: Whether the class has an *attrs*-generated ``__str__`` method.
2839+
str (bool):
2840+
Whether the class has an *attrs*-generated ``__str__`` method.
28322841
2833-
getstate_setstate:
2842+
getstate_setstate (bool):
28342843
Whether the class has *attrs*-generated ``__getstate__`` and
28352844
``__setstate__`` methods for `pickle`.
28362845
2837-
on_setattr: Whether the class has a ``__setattr__`` hook.
2846+
on_setattr (Callable[[Any, Attribute[Any], Any], Any] | None):
2847+
The class's ``__setattr__`` hook.
28382848
2839-
field_transformer:
2840-
Whether the class has `field transformers <transform-fields>`.
2849+
field_transformer (Callable[[Attribute[Any]], Attribute[Any]] | None):
2850+
The class's `field transformers <transform-fields>`.
28412851
28422852
.. versionadded:: 25.4.0
28432853
"""

0 commit comments

Comments
 (0)