METADATA 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. Metadata-Version: 2.1
  2. Name: attrs
  3. Version: 23.2.0
  4. Summary: Classes Without Boilerplate
  5. Project-URL: Documentation, https://www.attrs.org/
  6. Project-URL: Changelog, https://www.attrs.org/en/stable/changelog.html
  7. Project-URL: GitHub, https://github.com/python-attrs/attrs
  8. Project-URL: Funding, https://github.com/sponsors/hynek
  9. Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=pypi
  10. Author-email: Hynek Schlawack <hs@ox.cx>
  11. License-Expression: MIT
  12. License-File: LICENSE
  13. Keywords: attribute,boilerplate,class
  14. Classifier: Development Status :: 5 - Production/Stable
  15. Classifier: License :: OSI Approved :: MIT License
  16. Classifier: Programming Language :: Python :: 3.7
  17. Classifier: Programming Language :: Python :: 3.8
  18. Classifier: Programming Language :: Python :: 3.9
  19. Classifier: Programming Language :: Python :: 3.10
  20. Classifier: Programming Language :: Python :: 3.11
  21. Classifier: Programming Language :: Python :: 3.12
  22. Classifier: Programming Language :: Python :: Implementation :: CPython
  23. Classifier: Programming Language :: Python :: Implementation :: PyPy
  24. Classifier: Typing :: Typed
  25. Requires-Python: >=3.7
  26. Requires-Dist: importlib-metadata; python_version < '3.8'
  27. Provides-Extra: cov
  28. Requires-Dist: attrs[tests]; extra == 'cov'
  29. Requires-Dist: coverage[toml]>=5.3; extra == 'cov'
  30. Provides-Extra: dev
  31. Requires-Dist: attrs[tests]; extra == 'dev'
  32. Requires-Dist: pre-commit; extra == 'dev'
  33. Provides-Extra: docs
  34. Requires-Dist: furo; extra == 'docs'
  35. Requires-Dist: myst-parser; extra == 'docs'
  36. Requires-Dist: sphinx; extra == 'docs'
  37. Requires-Dist: sphinx-notfound-page; extra == 'docs'
  38. Requires-Dist: sphinxcontrib-towncrier; extra == 'docs'
  39. Requires-Dist: towncrier; extra == 'docs'
  40. Requires-Dist: zope-interface; extra == 'docs'
  41. Provides-Extra: tests
  42. Requires-Dist: attrs[tests-no-zope]; extra == 'tests'
  43. Requires-Dist: zope-interface; extra == 'tests'
  44. Provides-Extra: tests-mypy
  45. Requires-Dist: mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-mypy'
  46. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-mypy'
  47. Provides-Extra: tests-no-zope
  48. Requires-Dist: attrs[tests-mypy]; extra == 'tests-no-zope'
  49. Requires-Dist: cloudpickle; (platform_python_implementation == 'CPython') and extra == 'tests-no-zope'
  50. Requires-Dist: hypothesis; extra == 'tests-no-zope'
  51. Requires-Dist: pympler; extra == 'tests-no-zope'
  52. Requires-Dist: pytest-xdist[psutil]; extra == 'tests-no-zope'
  53. Requires-Dist: pytest>=4.3.0; extra == 'tests-no-zope'
  54. Description-Content-Type: text/markdown
  55. <p align="center">
  56. <a href="https://www.attrs.org/">
  57. <img src="https://raw.githubusercontent.com/python-attrs/attrs/main/docs/_static/attrs_logo.svg" width="35%" alt="attrs" />
  58. </a>
  59. </p>
  60. *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 methods](https://www.attrs.org/en/latest/glossary.html#term-dunder-methods)).
  61. [Trusted by NASA](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/personalizing-your-profile#list-of-qualifying-repositories-for-mars-2020-helicopter-contributor-achievement) for Mars missions since 2020!
  62. Its main goal is to help you to write **concise** and **correct** software without slowing down your code.
  63. ## Sponsors
  64. *attrs* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).
  65. Especially those generously supporting us at the *The Organization* tier and higher:
  66. <p align="center">
  67. <a href="https://www.variomedia.de/"><img src="https://www.attrs.org/en/23.2.0/_static/sponsors/Variomedia.svg" width="200" height="60" /></a>
  68. <a href="https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo"><img src="https://www.attrs.org/en/23.2.0/_static/sponsors/Tidelift.svg" width="200" height="60" /></a>
  69. <a href="https://filepreviews.io/"><img src="https://www.attrs.org/en/23.2.0/_static/sponsors/FilePreviews.svg" width="200" height="60"/></a>
  70. </p>
  71. <p align="center">
  72. <strong>Please consider <a href="https://github.com/sponsors/hynek">joining them</a> to help make <em>attrs</em>’s maintenance more sustainable!</strong>
  73. </p>
  74. <!-- teaser-end -->
  75. ## Example
  76. *attrs* gives you a class decorator and a way to declaratively define the attributes on that class:
  77. <!-- code-begin -->
  78. ```pycon
  79. >>> from attrs import asdict, define, make_class, Factory
  80. >>> @define
  81. ... class SomeClass:
  82. ... a_number: int = 42
  83. ... list_of_numbers: list[int] = 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. >>> asdict(sc)
  97. {'a_number': 1, 'list_of_numbers': [1, 2, 3]}
  98. >>> SomeClass()
  99. SomeClass(a_number=42, list_of_numbers=[])
  100. >>> C = make_class("C", ["a", "b"])
  101. >>> C("foo", "bar")
  102. C(a='foo', b='bar')
  103. ```
  104. After *declaring* your attributes, *attrs* gives you:
  105. - a concise and explicit overview of the class's attributes,
  106. - a nice human-readable `__repr__`,
  107. - equality-checking methods,
  108. - an initializer,
  109. - and much more,
  110. *without* writing dull boilerplate code again and again and *without* runtime performance penalties.
  111. **Hate type annotations**!?
  112. No problem!
  113. Types are entirely **optional** with *attrs*.
  114. Simply assign `attrs.field()` to the attributes instead of annotating them with types.
  115. ---
  116. This example uses *attrs*'s modern APIs that have been introduced in version 20.1.0, and the *attrs* package import name that has been added in version 21.3.0.
  117. The classic APIs (`@attr.s`, `attr.ib`, plus their serious-business aliases) and the `attr` package import name will remain **indefinitely**.
  118. Please check out [*On The Core API Names*](https://www.attrs.org/en/latest/names.html) for a more in-depth explanation.
  119. ## Data Classes
  120. On the tin, *attrs* might remind you of `dataclasses` (and indeed, `dataclasses` [are a descendant](https://hynek.me/articles/import-attrs/) of *attrs*).
  121. In practice it does a lot more and is more flexible.
  122. For instance it allows you to define [special handling of NumPy arrays for equality checks](https://www.attrs.org/en/stable/comparison.html#customization), allows more ways to [plug into the initialization process](https://www.attrs.org/en/stable/init.html#hooking-yourself-into-initialization), and allows for stepping through the generated methods using a debugger.
  123. For more details, please refer to our [comparison page](https://www.attrs.org/en/stable/why.html#data-classes).
  124. ## Project Information
  125. - [**Changelog**](https://www.attrs.org/en/stable/changelog.html)
  126. - [**Documentation**](https://www.attrs.org/)
  127. - [**PyPI**](https://pypi.org/project/attrs/)
  128. - [**Source Code**](https://github.com/python-attrs/attrs)
  129. - [**Contributing**](https://github.com/python-attrs/attrs/blob/main/.github/CONTRIBUTING.md)
  130. - [**Third-party Extensions**](https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs)
  131. - **Get Help**: please use the `python-attrs` tag on [StackOverflow](https://stackoverflow.com/questions/tagged/python-attrs)
  132. ### *attrs* for Enterprise
  133. Available as part of the Tidelift Subscription.
  134. The maintainers of *attrs* and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications.
  135. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.
  136. [Learn more.](https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
  137. ## Release Information
  138. ### Changes
  139. - The type annotation for `attrs.resolve_types()` is now correct.
  140. [#1141](https://github.com/python-attrs/attrs/issues/1141)
  141. - Type stubs now use `typing.dataclass_transform` to decorate dataclass-like decorators, instead of the non-standard `__dataclass_transform__` special form, which is only supported by Pyright.
  142. [#1158](https://github.com/python-attrs/attrs/issues/1158)
  143. - Fixed serialization of namedtuple fields using `attrs.asdict/astuple()` with `retain_collection_types=True`.
  144. [#1165](https://github.com/python-attrs/attrs/issues/1165)
  145. - `attrs.AttrsInstance` is now a `typing.Protocol` in both type hints and code.
  146. This allows you to subclass it along with another `Protocol`.
  147. [#1172](https://github.com/python-attrs/attrs/issues/1172)
  148. - If *attrs* detects that `__attrs_pre_init__` accepts more than just `self`, it will call it with the same arguments as `__init__` was called.
  149. This allows you to, for example, pass arguments to `super().__init__()`.
  150. [#1187](https://github.com/python-attrs/attrs/issues/1187)
  151. - Slotted classes now transform `functools.cached_property` decorated methods to support equivalent semantics.
  152. [#1200](https://github.com/python-attrs/attrs/issues/1200)
  153. - Added *class_body* argument to `attrs.make_class()` to provide additional attributes for newly created classes.
  154. It is, for example, now possible to attach methods.
  155. [#1203](https://github.com/python-attrs/attrs/issues/1203)
  156. ---
  157. [Full changelog](https://www.attrs.org/en/stable/changelog.html)