You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.rst
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,17 @@ The third digit is only for regressions.
11
11
Changes:
12
12
^^^^^^^^
13
13
14
+
- Add ``attr.astuple()`` that -- similarly to ``attr.asdict()`` -- returns the instance as a tuple.
15
+
`#77 <https://github.com/hynek/attrs/issues/77>`_
14
16
- Converts now work with frozen classes.
15
17
`#76 <https://github.com/hynek/attrs/issues/76>`_
16
18
- Instantiation of ``attrs`` classes with converters is now significantly faster.
17
19
`#80 <https://github.com/hynek/attrs/pull/80>`_
18
20
- Pickling now works with ``__slots__`` classes.
19
21
`#81 <https://github.com/hynek/attrs/issues/81>`_
20
-
- ``attr.assoc`` now works with ``__slots__`` classes.
22
+
- ``attr.assoc()`` now works with ``__slots__`` classes.
21
23
`#84 <https://github.com/hynek/attrs/issues/84>`_
22
-
- The tuple returned by ``attr.fields`` now also allows to access the ``Attribute`` instances by name.
24
+
- The tuple returned by ``attr.fields()`` now also allows to access the ``Attribute`` instances by name.
23
25
Yes, we've subclassed ``tuple`` so you don't have to!
24
26
Therefore ``attr.fields(C).x`` is equivalent to the deprecated ``C.x`` and works with ``__slots__`` classes.
25
27
`#88 <https://github.com/hynek/attrs/issues/88>`_
@@ -43,7 +45,7 @@ Deprecations:
43
45
^^^^^^^^^^^^^
44
46
45
47
- Accessing ``Attribute`` instances on class objects is now deprecated and will stop working in 2017.
46
-
If you need introspection please use the ``__attrs_attrs__`` attribute or the ``attr.fields`` function that carry them too.
48
+
If you need introspection please use the ``__attrs_attrs__`` attribute or the ``attr.fields()`` function that carry them too.
47
49
In the future, the attributes that are defined on the class body and are usually overwritten in your ``__init__`` method are simply removed after ``@attr.s`` has been applied.
48
50
49
51
This will remove the confusing error message if you write your own ``__init__`` and forget to initialize some attribute.
@@ -56,15 +58,15 @@ Deprecations:
56
58
Changes:
57
59
^^^^^^^^
58
60
59
-
- ``attr.asdict``\ 's ``dict_factory`` arguments is now propagated on recursion.
61
+
- ``attr.asdict()``\ 's ``dict_factory`` arguments is now propagated on recursion.
60
62
`#45 <https://github.com/hynek/attrs/issues/45>`_
61
-
- ``attr.asdict``, ``attr.has`` and ``attr.fields`` are significantly faster.
63
+
- ``attr.asdict()``, ``attr.has()`` and ``attr.fields()`` are significantly faster.
62
64
`#48 <https://github.com/hynek/attrs/issues/48>`_
63
65
`#51 <https://github.com/hynek/attrs/issues/51>`_
64
66
- Add ``attr.attrs`` and ``attr.attrib`` as a more consistent aliases for ``attr.s`` and ``attr.ib``.
65
67
- Add ``frozen`` option to ``attr.s`` that will make instances best-effort immutable.
66
68
`#60 <https://github.com/hynek/attrs/issues/60>`_
67
-
- ``attr.asdict`` now takes ``retain_collection_types`` as an argument.
69
+
- ``attr.asdict()`` now takes ``retain_collection_types`` as an argument.
68
70
If ``True``, it does not convert attributes of type ``tuple`` or ``set`` to ``list``.
69
71
`#69 <https://github.com/hynek/attrs/issues/69>`_
70
72
@@ -95,7 +97,7 @@ Changes:
95
97
- Allow the case of initializing attributes that are set to ``init=False``.
96
98
This allows for clean initializer parameter lists while being able to initialize attributes to default values.
97
99
`#32 <https://github.com/hynek/attrs/issues/32>`_
98
-
- ``attr.asdict`` can now produce arbitrary mappings instead of Python ``dict``\ s when provided with a ``dict_factory`` argument.
100
+
- ``attr.asdict()`` can now produce arbitrary mappings instead of Python ``dict``\ s when provided with a ``dict_factory`` argument.
Copy file name to clipboardExpand all lines: docs/examples.rst
+25-2Lines changed: 25 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,8 +162,8 @@ On Python 3 it overrides the implicit detection.
162
162
163
163
.. _asdict:
164
164
165
-
Converting to Dictionaries
166
-
--------------------------
165
+
Converting to Collections Types
166
+
-------------------------------
167
167
168
168
When you have a class with data, it often is very convenient to transform that class into a :class:`dict` (for example if you want to serialize it to JSON):
169
169
@@ -210,6 +210,29 @@ For the common case where you want to :func:`include <attr.filters.include>` or
0 commit comments