Skip to content

Commit d4e3220

Browse files
committed
Use attrs namespace throughout examples.rst
1 parent bab5d13 commit d4e3220

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

docs/examples.rst

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The simplest possible usage is:
99

1010
.. doctest::
1111

12-
>>> from attr import define
12+
>>> from attrs import define
1313
>>> @define
1414
... class Empty:
1515
... pass
@@ -189,18 +189,16 @@ When you have a class with data, it often is very convenient to transform that c
189189

190190
.. doctest::
191191

192-
>>> from attr import asdict
192+
>>> from attrs import asdict
193193

194194
>>> asdict(Coordinates(x=1, y=2))
195195
{'x': 1, 'y': 2}
196196

197197
Some fields cannot or should not be transformed.
198-
For that, `attr.asdict` offers a callback that decides whether an attribute should be included:
198+
For that, `attrs.asdict` offers a callback that decides whether an attribute should be included:
199199

200200
.. doctest::
201201

202-
>>> from attr import asdict
203-
204202
>>> @define
205203
... class User(object):
206204
... email: str
@@ -219,7 +217,7 @@ For the common case where you want to `include <attr.filters.include>` or `exclu
219217

220218
.. doctest::
221219

222-
>>> from attr import asdict, filters, fields
220+
>>> from attrs import asdict, filters, fields
223221

224222
>>> @define
225223
... class User:
@@ -247,7 +245,7 @@ Other times, all you want is a tuple and ``attrs`` won't let you down:
247245
.. doctest::
248246

249247
>>> import sqlite3
250-
>>> from attr import astuple
248+
>>> from attrs import astuple
251249

252250
>>> @define
253251
... class Foo:
@@ -363,7 +361,7 @@ You can use a decorator:
363361

364362
.. doctest::
365363

366-
>>> from attr import validators
364+
>>> from attrs import validators
367365

368366
>>> def x_smaller_than_y(instance, attribute, value):
369367
... if value >= instance.y:
@@ -454,7 +452,7 @@ All ``attrs`` attributes may include arbitrary metadata in the form of a read-on
454452

455453
.. doctest::
456454

457-
>>> from attr import fields
455+
>>> from attrs import fields
458456

459457
>>> @define
460458
... class C:
@@ -478,7 +476,7 @@ Types
478476

479477
.. doctest::
480478

481-
>>> from attr import attrib, fields
479+
>>> from attrs import attrib, fields
482480

483481
>>> @define
484482
... class C:
@@ -497,7 +495,7 @@ If you don't mind annotating *all* attributes, you can even drop the `attrs.fiel
497495
.. doctest::
498496

499497
>>> import typing
500-
>>> from attr import fields
498+
>>> from attrs import fields
501499

502500
>>> @define
503501
... class AutoC:
@@ -527,7 +525,7 @@ This will replace the *type* attribute in the respective fields.
527525

528526
.. doctest::
529527

530-
>>> from attr import fields, resolve_types
528+
>>> from attrs import fields, resolve_types
531529

532530
>>> @define
533531
... class A:
@@ -604,7 +602,7 @@ In Clojure that function is called `assoc <https://clojuredocs.org/clojure.core/
604602

605603
.. doctest::
606604

607-
>>> from attr import evolve
605+
>>> from attrs import evolve
608606

609607
>>> @frozen
610608
... class C:
@@ -641,7 +639,7 @@ You can still have power over the attributes if you pass a dictionary of name: `
641639

642640
.. doctest::
643641

644-
>>> from attr import make_class
642+
>>> from attrs import make_class
645643

646644
>>> C = make_class("C", {"x": field(default=42),
647645
... "y": field(default=Factory(list))},
@@ -658,7 +656,7 @@ If you need to dynamically make a class with `attrs.make_class` and it needs to
658656

659657
.. doctest::
660658

661-
>>> from attr import make_class
659+
>>> from attrs import make_class
662660

663661
>>> class D:
664662
... def __eq__(self, other):

0 commit comments

Comments
 (0)