You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
11 KiB

4 years ago
  1. Metadata-Version: 2.1
  2. Name: attrs
  3. Version: 18.2.0
  4. Summary: Classes Without Boilerplate
  5. Home-page: https://www.attrs.org/
  6. Author: Hynek Schlawack
  7. Author-email: hs@ox.cx
  8. Maintainer: Hynek Schlawack
  9. Maintainer-email: hs@ox.cx
  10. License: MIT
  11. Project-URL: Documentation, https://www.attrs.org/
  12. Project-URL: Bug Tracker, https://github.com/python-attrs/attrs/issues
  13. Project-URL: Source Code, https://github.com/python-attrs/attrs
  14. Keywords: class,attribute,boilerplate
  15. Platform: UNKNOWN
  16. Classifier: Development Status :: 5 - Production/Stable
  17. Classifier: Intended Audience :: Developers
  18. Classifier: Natural Language :: English
  19. Classifier: License :: OSI Approved :: MIT License
  20. Classifier: Operating System :: OS Independent
  21. Classifier: Programming Language :: Python
  22. Classifier: Programming Language :: Python :: 2
  23. Classifier: Programming Language :: Python :: 2.7
  24. Classifier: Programming Language :: Python :: 3
  25. Classifier: Programming Language :: Python :: 3.4
  26. Classifier: Programming Language :: Python :: 3.5
  27. Classifier: Programming Language :: Python :: 3.6
  28. Classifier: Programming Language :: Python :: 3.7
  29. Classifier: Programming Language :: Python :: Implementation :: CPython
  30. Classifier: Programming Language :: Python :: Implementation :: PyPy
  31. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  32. Provides-Extra: docs
  33. Provides-Extra: dev
  34. Provides-Extra: tests
  35. Provides-Extra: dev
  36. Requires-Dist: coverage; extra == 'dev'
  37. Requires-Dist: hypothesis; extra == 'dev'
  38. Requires-Dist: pympler; extra == 'dev'
  39. Requires-Dist: pytest; extra == 'dev'
  40. Requires-Dist: six; extra == 'dev'
  41. Requires-Dist: zope.interface; extra == 'dev'
  42. Requires-Dist: sphinx; extra == 'dev'
  43. Requires-Dist: zope.interface; extra == 'dev'
  44. Requires-Dist: pre-commit; extra == 'dev'
  45. Provides-Extra: docs
  46. Requires-Dist: sphinx; extra == 'docs'
  47. Requires-Dist: zope.interface; extra == 'docs'
  48. Provides-Extra: tests
  49. Requires-Dist: coverage; extra == 'tests'
  50. Requires-Dist: hypothesis; extra == 'tests'
  51. Requires-Dist: pympler; extra == 'tests'
  52. Requires-Dist: pytest; extra == 'tests'
  53. Requires-Dist: six; extra == 'tests'
  54. Requires-Dist: zope.interface; extra == 'tests'
  55. .. image:: https://www.attrs.org/en/latest/_static/attrs_logo.png
  56. :alt: attrs Logo
  57. ======================================
  58. ``attrs``: Classes Without Boilerplate
  59. ======================================
  60. .. image:: https://readthedocs.org/projects/attrs/badge/?version=stable
  61. :target: https://www.attrs.org/en/stable/?badge=stable
  62. :alt: Documentation Status
  63. .. image:: https://travis-ci.org/python-attrs/attrs.svg?branch=master
  64. :target: https://travis-ci.org/python-attrs/attrs
  65. :alt: CI Status
  66. .. image:: https://codecov.io/github/python-attrs/attrs/branch/master/graph/badge.svg
  67. :target: https://codecov.io/github/python-attrs/attrs
  68. :alt: Test Coverage
  69. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  70. :target: https://github.com/ambv/black
  71. :alt: Code style: black
  72. .. teaser-begin
  73. ``attrs`` is the Python package that will bring back the **joy** of **writing classes** by relieving you from the drudgery of implementing object protocols (aka `dunder <https://nedbatchelder.com/blog/200605/dunder.html>`_ methods).
  74. Its main goal is to help you to write **concise** and **correct** software without slowing down your code.
  75. .. -spiel-end-
  76. For that, it gives you a class decorator and a way to declaratively define the attributes on that class:
  77. .. -code-begin-
  78. .. code-block:: pycon
  79. >>> import attr
  80. >>> @attr.s
  81. ... class SomeClass(object):
  82. ... a_number = attr.ib(default=42)
  83. ... list_of_numbers = attr.ib(factory=list)
  84. ...
  85. ... def hard_math(self, another_number):
  86. ... return self.a_number + sum(self.list_of_numbers) * another_number
  87. >>> sc = SomeClass(1, [1, 2, 3])
  88. >>> sc
  89. SomeClass(a_number=1, list_of_numbers=[1, 2, 3])
  90. >>> sc.hard_math(3)
  91. 19
  92. >>> sc == SomeClass(1, [1, 2, 3])
  93. True
  94. >>> sc != SomeClass(2, [3, 2, 1])
  95. True
  96. >>> attr.asdict(sc)
  97. {'a_number': 1, 'list_of_numbers': [1, 2, 3]}
  98. >>> SomeClass()
  99. SomeClass(a_number=42, list_of_numbers=[])
  100. >>> C = attr.make_class("C", ["a", "b"])
  101. >>> C("foo", "bar")
  102. C(a='foo', b='bar')
  103. After *declaring* your attributes ``attrs`` gives you:
  104. - a concise and explicit overview of the class's attributes,
  105. - a nice human-readable ``__repr__``,
  106. - a complete set of comparison methods,
  107. - an initializer,
  108. - and much more,
  109. *without* writing dull boilerplate code again and again and *without* runtime performance penalties.
  110. On Python 3.6 and later, you can often even drop the calls to ``attr.ib()`` by using `type annotations <https://www.attrs.org/en/latest/types.html>`_.
  111. This gives you the power to use actual classes with actual types in your code instead of confusing ``tuple``\ s or `confusingly behaving <https://www.attrs.org/en/stable/why.html#namedtuples>`_ ``namedtuple``\ s.
  112. Which in turn encourages you to write *small classes* that do `one thing well <https://www.destroyallsoftware.com/talks/boundaries>`_.
  113. Never again violate the `single responsibility principle <https://en.wikipedia.org/wiki/Single_responsibility_principle>`_ just because implementing ``__init__`` et al is a painful drag.
  114. .. -testimonials-
  115. Testimonials
  116. ============
  117. **Amber Hawkie Brown**, Twisted Release Manager and Computer Owl:
  118. Writing a fully-functional class using attrs takes me less time than writing this testimonial.
  119. **Glyph Lefkowitz**, creator of `Twisted <https://twistedmatrix.com/>`_, `Automat <https://pypi.org/project/Automat/>`_, and other open source software, in `The One Python Library Everyone Needs <https://glyph.twistedmatrix.com/2016/08/attrs.html>`_:
  120. I’m looking forward to is being able to program in Python-with-attrs everywhere.
  121. It exerts a subtle, but positive, design influence in all the codebases I’ve see it used in.
  122. **Kenneth Reitz**, author of `Requests <http://www.python-requests.org/>`_ and Developer Advocate at DigitalOcean, (`on paper no less <https://twitter.com/hynek/status/866817877650751488>`_!):
  123. attrs—classes for humans. I like it.
  124. **Łukasz Langa**, prolific CPython core developer and Production Engineer at Facebook:
  125. I'm increasingly digging your attr.ocity. Good job!
  126. .. -end-
  127. .. -project-information-
  128. Getting Help
  129. ============
  130. Please use the ``python-attrs`` tag on `StackOverflow <https://stackoverflow.com/questions/tagged/python-attrs>`_ to get help.
  131. Answering questions of your fellow developers is also great way to help the project!
  132. Project Information
  133. ===================
  134. ``attrs`` is released under the `MIT <https://choosealicense.com/licenses/mit/>`_ license,
  135. its documentation lives at `Read the Docs <https://www.attrs.org/>`_,
  136. the code on `GitHub <https://github.com/python-attrs/attrs>`_,
  137. and the latest release on `PyPI <https://pypi.org/project/attrs/>`_.
  138. It’s rigorously tested on Python 2.7, 3.4+, and PyPy.
  139. We collect information on **third-party extensions** in our `wiki <https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs>`_.
  140. Feel free to browse and add your own!
  141. If you'd like to contribute to ``attrs`` you're most welcome and we've written `a little guide <https://www.attrs.org/en/latest/contributing.html>`_ to get you started!
  142. Release Information
  143. ===================
  144. 18.2.0 (2018-09-01)
  145. -------------------
  146. Deprecations
  147. ^^^^^^^^^^^^
  148. - Comparing subclasses using ``<``, ``>``, ``<=``, and ``>=`` is now deprecated.
  149. The docs always claimed that instances are only compared if the types are identical, so this is a first step to conform to the docs.
  150. Equality operators (``==`` and ``!=``) were always strict in this regard.
  151. `#394 <https://github.com/python-attrs/attrs/issues/394>`_
  152. Changes
  153. ^^^^^^^
  154. - ``attrs`` now ships its own `PEP 484 <https://www.python.org/dev/peps/pep-0484/>`_ type hints.
  155. Together with `mypy <http://mypy-lang.org>`_'s ``attrs`` plugin, you've got all you need for writing statically typed code in both Python 2 and 3!
  156. At that occasion, we've also added `narrative docs <https://www.attrs.org/en/stable/types.html>`_ about type annotations in ``attrs``.
  157. `#238 <https://github.com/python-attrs/attrs/issues/238>`_
  158. - Added *kw_only* arguments to ``attr.ib`` and ``attr.s``, and a corresponding *kw_only* attribute to ``attr.Attribute``.
  159. This change makes it possible to have a generated ``__init__`` with keyword-only arguments on Python 3, relaxing the required ordering of default and non-default valued attributes.
  160. `#281 <https://github.com/python-attrs/attrs/issues/281>`_,
  161. `#411 <https://github.com/python-attrs/attrs/issues/411>`_
  162. - The test suite now runs with ``hypothesis.HealthCheck.too_slow`` disabled to prevent CI breakage on slower computers.
  163. `#364 <https://github.com/python-attrs/attrs/issues/364>`_,
  164. `#396 <https://github.com/python-attrs/attrs/issues/396>`_
  165. - ``attr.validators.in_()`` now raises a ``ValueError`` with a useful message even if the options are a string and the value is not a string.
  166. `#383 <https://github.com/python-attrs/attrs/issues/383>`_
  167. - ``attr.asdict()`` now properly handles deeply nested lists and dictionaries.
  168. `#395 <https://github.com/python-attrs/attrs/issues/395>`_
  169. - Added ``attr.converters.default_if_none()`` that allows to replace ``None`` values in attributes.
  170. For example ``attr.ib(converter=default_if_none(""))`` replaces ``None`` by empty strings.
  171. `#400 <https://github.com/python-attrs/attrs/issues/400>`_,
  172. `#414 <https://github.com/python-attrs/attrs/issues/414>`_
  173. - Fixed a reference leak where the original class would remain live after being replaced when ``slots=True`` is set.
  174. `#407 <https://github.com/python-attrs/attrs/issues/407>`_
  175. - Slotted classes can now be made weakly referenceable by passing ``@attr.s(weakref_slot=True)``.
  176. `#420 <https://github.com/python-attrs/attrs/issues/420>`_
  177. - Added *cache_hash* option to ``@attr.s`` which causes the hash code to be computed once and stored on the object.
  178. `#425 <https://github.com/python-attrs/attrs/issues/425>`_
  179. - Attributes can be named ``property`` and ``itemgetter`` now.
  180. `#430 <https://github.com/python-attrs/attrs/issues/430>`_
  181. - It is now possible to override a base class' class variable using only class annotations.
  182. `#431 <https://github.com/python-attrs/attrs/issues/431>`_
  183. `Full changelog <https://www.attrs.org/en/stable/changelog.html>`_.
  184. Credits
  185. =======
  186. ``attrs`` is written and maintained by `Hynek Schlawack <https://hynek.me/>`_.
  187. The development is kindly supported by `Variomedia AG <https://www.variomedia.de/>`_.
  188. A full list of contributors can be found in `GitHub's overview <https://github.com/python-attrs/attrs/graphs/contributors>`_.
  189. It’s the spiritual successor of `characteristic <https://characteristic.readthedocs.io/>`_ and aspires to fix some of it clunkiness and unfortunate decisions.
  190. Both were inspired by Twisted’s `FancyEqMixin <https://twistedmatrix.com/documents/current/api/twisted.python.util.FancyEqMixin.html>`_ but both are implemented using class decorators because `subclassing is bad for you <https://www.youtube.com/watch?v=3MNVP9-hglc>`_, m’kay?