METADATA 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. Metadata-Version: 2.4
  2. Name: attrs
  3. Version: 25.3.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: Programming Language :: Python :: 3.8
  16. Classifier: Programming Language :: Python :: 3.9
  17. Classifier: Programming Language :: Python :: 3.10
  18. Classifier: Programming Language :: Python :: 3.11
  19. Classifier: Programming Language :: Python :: 3.12
  20. Classifier: Programming Language :: Python :: 3.13
  21. Classifier: Programming Language :: Python :: Implementation :: CPython
  22. Classifier: Programming Language :: Python :: Implementation :: PyPy
  23. Classifier: Typing :: Typed
  24. Requires-Python: >=3.8
  25. Provides-Extra: benchmark
  26. Requires-Dist: cloudpickle; (platform_python_implementation == 'CPython') and extra == 'benchmark'
  27. Requires-Dist: hypothesis; extra == 'benchmark'
  28. Requires-Dist: mypy>=1.11.1; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'benchmark'
  29. Requires-Dist: pympler; extra == 'benchmark'
  30. Requires-Dist: pytest-codspeed; extra == 'benchmark'
  31. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'benchmark'
  32. Requires-Dist: pytest-xdist[psutil]; extra == 'benchmark'
  33. Requires-Dist: pytest>=4.3.0; extra == 'benchmark'
  34. Provides-Extra: cov
  35. Requires-Dist: cloudpickle; (platform_python_implementation == 'CPython') and extra == 'cov'
  36. Requires-Dist: coverage[toml]>=5.3; extra == 'cov'
  37. Requires-Dist: hypothesis; extra == 'cov'
  38. Requires-Dist: mypy>=1.11.1; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'cov'
  39. Requires-Dist: pympler; extra == 'cov'
  40. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'cov'
  41. Requires-Dist: pytest-xdist[psutil]; extra == 'cov'
  42. Requires-Dist: pytest>=4.3.0; extra == 'cov'
  43. Provides-Extra: dev
  44. Requires-Dist: cloudpickle; (platform_python_implementation == 'CPython') and extra == 'dev'
  45. Requires-Dist: hypothesis; extra == 'dev'
  46. Requires-Dist: mypy>=1.11.1; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'dev'
  47. Requires-Dist: pre-commit-uv; extra == 'dev'
  48. Requires-Dist: pympler; extra == 'dev'
  49. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'dev'
  50. Requires-Dist: pytest-xdist[psutil]; extra == 'dev'
  51. Requires-Dist: pytest>=4.3.0; extra == 'dev'
  52. Provides-Extra: docs
  53. Requires-Dist: cogapp; extra == 'docs'
  54. Requires-Dist: furo; extra == 'docs'
  55. Requires-Dist: myst-parser; extra == 'docs'
  56. Requires-Dist: sphinx; extra == 'docs'
  57. Requires-Dist: sphinx-notfound-page; extra == 'docs'
  58. Requires-Dist: sphinxcontrib-towncrier; extra == 'docs'
  59. Requires-Dist: towncrier; extra == 'docs'
  60. Provides-Extra: tests
  61. Requires-Dist: cloudpickle; (platform_python_implementation == 'CPython') and extra == 'tests'
  62. Requires-Dist: hypothesis; extra == 'tests'
  63. Requires-Dist: mypy>=1.11.1; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'tests'
  64. Requires-Dist: pympler; extra == 'tests'
  65. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'tests'
  66. Requires-Dist: pytest-xdist[psutil]; extra == 'tests'
  67. Requires-Dist: pytest>=4.3.0; extra == 'tests'
  68. Provides-Extra: tests-mypy
  69. Requires-Dist: mypy>=1.11.1; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'tests-mypy'
  70. Requires-Dist: pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.10') and extra == 'tests-mypy'
  71. Description-Content-Type: text/markdown
  72. <p align="center">
  73. <a href="https://www.attrs.org/">
  74. <img src="https://raw.githubusercontent.com/python-attrs/attrs/main/docs/_static/attrs_logo.svg" width="35%" alt="attrs" />
  75. </a>
  76. </p>
  77. *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)).
  78. [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!
  79. Its main goal is to help you to write **concise** and **correct** software without slowing down your code.
  80. ## Sponsors
  81. *attrs* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).
  82. Especially those generously supporting us at the *The Organization* tier and higher:
  83. <!-- sponsor-break-begin -->
  84. <p align="center">
  85. <!-- [[[cog
  86. import pathlib, tomllib
  87. for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
  88. print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="https://www.attrs.org/en/25.3.0/_static/sponsors/{sponsor["img"]}" width="190" /></a>')
  89. ]]] -->
  90. <a href="https://www.variomedia.de/"><img title="Variomedia AG" src="https://www.attrs.org/en/25.3.0/_static/sponsors/Variomedia.svg" width="190" /></a>
  91. <a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="https://www.attrs.org/en/25.3.0/_static/sponsors/Tidelift.svg" width="190" /></a>
  92. <a href="https://klaviyo.com/"><img title="Klaviyo" src="https://www.attrs.org/en/25.3.0/_static/sponsors/Klaviyo.svg" width="190" /></a>
  93. <a href="https://privacy-solutions.org/"><img title="Privacy Solutions" src="https://www.attrs.org/en/25.3.0/_static/sponsors/Privacy-Solutions.svg" width="190" /></a>
  94. <a href="https://www.emsys-renewables.com/"><img title="emsys renewables" src="https://www.attrs.org/en/25.3.0/_static/sponsors/emsys-renewables.svg" width="190" /></a>
  95. <a href="https://filepreviews.io/"><img title="FilePreviews" src="https://www.attrs.org/en/25.3.0/_static/sponsors/FilePreviews.svg" width="190" /></a>
  96. <a href="https://polar.sh/"><img title="Polar" src="https://www.attrs.org/en/25.3.0/_static/sponsors/Polar.svg" width="190" /></a>
  97. <!-- [[[end]]] -->
  98. </p>
  99. <!-- sponsor-break-end -->
  100. <p align="center">
  101. <strong>Please consider <a href="https://github.com/sponsors/hynek">joining them</a> to help make <em>attrs</em>’s maintenance more sustainable!</strong>
  102. </p>
  103. <!-- teaser-end -->
  104. ## Example
  105. *attrs* gives you a class decorator and a way to declaratively define the attributes on that class:
  106. <!-- code-begin -->
  107. ```pycon
  108. >>> from attrs import asdict, define, make_class, Factory
  109. >>> @define
  110. ... class SomeClass:
  111. ... a_number: int = 42
  112. ... list_of_numbers: list[int] = Factory(list)
  113. ...
  114. ... def hard_math(self, another_number):
  115. ... return self.a_number + sum(self.list_of_numbers) * another_number
  116. >>> sc = SomeClass(1, [1, 2, 3])
  117. >>> sc
  118. SomeClass(a_number=1, list_of_numbers=[1, 2, 3])
  119. >>> sc.hard_math(3)
  120. 19
  121. >>> sc == SomeClass(1, [1, 2, 3])
  122. True
  123. >>> sc != SomeClass(2, [3, 2, 1])
  124. True
  125. >>> asdict(sc)
  126. {'a_number': 1, 'list_of_numbers': [1, 2, 3]}
  127. >>> SomeClass()
  128. SomeClass(a_number=42, list_of_numbers=[])
  129. >>> C = make_class("C", ["a", "b"])
  130. >>> C("foo", "bar")
  131. C(a='foo', b='bar')
  132. ```
  133. After *declaring* your attributes, *attrs* gives you:
  134. - a concise and explicit overview of the class's attributes,
  135. - a nice human-readable `__repr__`,
  136. - equality-checking methods,
  137. - an initializer,
  138. - and much more,
  139. *without* writing dull boilerplate code again and again and *without* runtime performance penalties.
  140. ---
  141. 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.
  142. The classic APIs (`@attr.s`, `attr.ib`, plus their serious-business aliases) and the `attr` package import name will remain **indefinitely**.
  143. Check out [*On The Core API Names*](https://www.attrs.org/en/latest/names.html) for an in-depth explanation!
  144. ### Hate Type Annotations!?
  145. No problem!
  146. Types are entirely **optional** with *attrs*.
  147. Simply assign `attrs.field()` to the attributes instead of annotating them with types:
  148. ```python
  149. from attrs import define, field
  150. @define
  151. class SomeClass:
  152. a_number = field(default=42)
  153. list_of_numbers = field(factory=list)
  154. ```
  155. ## Data Classes
  156. On the tin, *attrs* might remind you of `dataclasses` (and indeed, `dataclasses` [are a descendant](https://hynek.me/articles/import-attrs/) of *attrs*).
  157. In practice it does a lot more and is more flexible.
  158. 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), has a replacement for `__init_subclass__`, and allows for stepping through the generated methods using a debugger.
  159. For more details, please refer to our [comparison page](https://www.attrs.org/en/stable/why.html#data-classes), but generally speaking, we are more likely to commit crimes against nature to make things work that one would expect to work, but that are quite complicated in practice.
  160. ## Project Information
  161. - [**Changelog**](https://www.attrs.org/en/stable/changelog.html)
  162. - [**Documentation**](https://www.attrs.org/)
  163. - [**PyPI**](https://pypi.org/project/attrs/)
  164. - [**Source Code**](https://github.com/python-attrs/attrs)
  165. - [**Contributing**](https://github.com/python-attrs/attrs/blob/main/.github/CONTRIBUTING.md)
  166. - [**Third-party Extensions**](https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs)
  167. - **Get Help**: use the `python-attrs` tag on [Stack Overflow](https://stackoverflow.com/questions/tagged/python-attrs)
  168. ### *attrs* for Enterprise
  169. Available as part of the [Tidelift Subscription](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek).
  170. 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.
  171. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.
  172. ## Release Information
  173. ### Changes
  174. - Restore support for generator-based `field_transformer`s.
  175. [#1417](https://github.com/python-attrs/attrs/issues/1417)
  176. ---
  177. [Full changelog →](https://www.attrs.org/en/stable/changelog.html)