Skip to content

Commit 5e9280a

Browse files
committed
docstring improvements referencing the attrs package
1 parent 657af01 commit 5e9280a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sumtypes.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ class MyType(object):
99
MyConstructor = constructor('x')
1010
AnotherConstructor = constructor('x', 'y')
1111
12-
# You can also make use of any feature of the excellent `attribs`_
13-
# package by using attr.ib instances in constructors
12+
# You can also make use of any feature of the attrs
13+
# package by using attr.ib in constructors
1414
ThirdConstructor = constructor(
15-
('one', attr.ib(default=42)))
15+
('one', attr.ib(default=42)),
16+
('two', attr.ib(validator=attr.validators.instance_of(int))))
17+
18+
(`attrs package`_, and `attr.ib documentation`_)
19+
20+
.. _`attrs package`: https://pypi.python.org/pypi/attrs
21+
.. _`attr.ib documentation`: http://attrs.readthedocs.org/en/stable/api.html#attr.ib
1622
1723
Then construct them by calling the constructors::
1824
@@ -74,7 +80,11 @@ def constructor(*argspec):
7480
Register a constructor for the parent sum type.
7581
7682
:param argspec: each argument should be either a simple string indicating
77-
the name of an attribute, or the result of :func:`attrib`.
83+
the name of an attribute, or two-tuples of ``(name, attr.ib(...))``
84+
where `attr.ib`_ is from the `attrs package`_.
85+
86+
.. _`attr.ib`:
87+
http://attrs.readthedocs.org/en/stable/api.html#attr.ib
7888
"""
7989
attrs = [(ib, attr.ib()) if not isinstance(ib, tuple) else ib
8090
for ib in argspec]

0 commit comments

Comments
 (0)