attrs v18.1.0 Release Notes

Release Date: 2018-05-03 // almost 6 years ago
  • ๐Ÿ”„ Changes ^

    • x=X(); x.cycle = x; repr(x) will no longer raise a RecursionError, and will instead show as X(x=...).

    #95 <https://github.com/python-attrs/attrs/issues/95>_

    • 0๏ธโƒฃ attr.ib(factory=f) is now syntactic sugar for the common case of attr.ib(default=attr.Factory(f)).

    #178 <https://github.com/python-attrs/attrs/issues/178>, #356 <https://github.com/python-attrs/attrs/issues/356>

    • โž• Added attr.field_dict() to return an ordered dictionary of attrs attributes for a class, whose keys are the attribute names.

    #290 <https://github.com/python-attrs/attrs/issues/290>, #349 <https://github.com/python-attrs/attrs/issues/349>

    • The order of attributes that are passed into attr.make_class() or the these argument of @attr.s() is now retained if the dictionary is ordered (i.e. dict on Python 3.6 and later, collections.OrderedDict otherwise).

    Before, the order was always determined by the order in which the attributes have been defined which may not be desirable when creating classes programmatically.

    #300 <https://github.com/python-attrs/attrs/issues/300>, #339 <https://github.com/python-attrs/attrs/issues/339>, #343 <https://github.com/python-attrs/attrs/issues/343>_

    • In slotted classes, __getstate__ and __setstate__ now ignore the __weakref__ attribute.

    #311 <https://github.com/python-attrs/attrs/issues/311>, #326 <https://github.com/python-attrs/attrs/issues/326>

    • Setting the cell type is now completely best effort. This fixes attrs on Jython.

    We cannot make any guarantees regarding Jython though, because our test suite cannot run due to dependency incompatibilities.

    #321 <https://github.com/python-attrs/attrs/issues/321>, #334 <https://github.com/python-attrs/attrs/issues/334>

    • If attr.s is passed a these argument, it will no longer attempt to remove attributes with the same name from the class body.

    #322 <https://github.com/python-attrs/attrs/issues/322>, #323 <https://github.com/python-attrs/attrs/issues/323>

    • ๐Ÿ— The hash of attr.NOTHING is now vegan and faster on 32bit Python builds.

    #331 <https://github.com/python-attrs/attrs/issues/331>, #332 <https://github.com/python-attrs/attrs/issues/332>

    • The overhead of instantiating frozen dict classes is virtually eliminated. #336 <https://github.com/python-attrs/attrs/issues/336>_
    • Generated __init__ methods now have an __annotations__ attribute derived from the types of the fields.

    #363 <https://github.com/python-attrs/attrs/issues/363>_

    • ๐Ÿ“š We have restructured the documentation a bit to account for attrs' growth in scope. Instead of putting everything into the examples <https://www.attrs.org/en/stable/examples.html>_ page, we have started to extract narrative chapters.

    So far, we've added chapters on initialization <https://www.attrs.org/en/stable/init.html>_ and hashing <https://www.attrs.org/en/stable/hashing.html>_.

    Expect more to come!

    #369 <https://github.com/python-attrs/attrs/issues/369>, #370 <https://github.com/python-attrs/attrs/issues/370>