experimental/cpu/: attrs-23.2.0 metadata and description

Simple index

Classes Without Boilerplate

author_email Hynek Schlawack <hs@ox.cx>
classifiers
  • Development Status :: 5 - Production/Stable
  • License :: OSI Approved :: MIT License
  • Programming Language :: Python :: 3.7
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
  • Programming Language :: Python :: Implementation :: CPython
  • Programming Language :: Python :: Implementation :: PyPy
  • Typing :: Typed
description_content_type text/markdown
keywords attribute,boilerplate,class
project_urls
  • Documentation, https://www.attrs.org/
  • Changelog, https://www.attrs.org/en/stable/changelog.html
  • GitHub, https://github.com/python-attrs/attrs
  • Funding, https://github.com/sponsors/hynek
  • Tidelift, https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=pypi
provides_extras tests-no-zope
requires_dist
  • importlib-metadata; python_version < '3.8'
  • cloudpickle; (platform_python_implementation == 'CPython') and extra == 'cov'
  • coverage[toml]>=5.3; extra == 'cov'
  • hypothesis; extra == 'cov'
  • mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'cov'
  • pympler; extra == 'cov'
  • pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'cov'
  • pytest-xdist[psutil]; extra == 'cov'
  • pytest>=4.3.0; extra == 'cov'
  • zope-interface; extra == 'cov'
  • cloudpickle; (platform_python_implementation == 'CPython') and extra == 'dev'
  • hypothesis; extra == 'dev'
  • mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'dev'
  • pre-commit; extra == 'dev'
  • pympler; extra == 'dev'
  • pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'dev'
  • pytest-xdist[psutil]; extra == 'dev'
  • pytest>=4.3.0; extra == 'dev'
  • zope-interface; extra == 'dev'
  • furo; extra == 'docs'
  • myst-parser; extra == 'docs'
  • sphinx; extra == 'docs'
  • sphinx-notfound-page; extra == 'docs'
  • sphinxcontrib-towncrier; extra == 'docs'
  • towncrier; extra == 'docs'
  • zope-interface; extra == 'docs'
  • cloudpickle; (platform_python_implementation == 'CPython') and extra == 'tests'
  • hypothesis; extra == 'tests'
  • mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests'
  • pympler; extra == 'tests'
  • pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests'
  • pytest-xdist[psutil]; extra == 'tests'
  • pytest>=4.3.0; extra == 'tests'
  • zope-interface; extra == 'tests'
  • mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-mypy'
  • pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-mypy'
  • cloudpickle; (platform_python_implementation == 'CPython') and extra == 'tests-no-zope'
  • hypothesis; extra == 'tests-no-zope'
  • mypy>=1.6; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-no-zope'
  • pympler; extra == 'tests-no-zope'
  • pytest-mypy-plugins; (platform_python_implementation == 'CPython' and python_version >= '3.8') and extra == 'tests-no-zope'
  • pytest-xdist[psutil]; extra == 'tests-no-zope'
  • pytest>=4.3.0; extra == 'tests-no-zope'
requires_python >=3.7
File Tox results History
attrs-23.2.0-py3-none-any.whl
Size
59 KB
Type
Python Wheel
Python
3

attrs

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). Trusted by NASA for Mars missions since 2020!

Its main goal is to help you to write concise and correct software without slowing down your code.

Sponsors

attrs would not be possible without our amazing sponsors. Especially those generously supporting us at the The Organization tier and higher:

Please consider joining them to help make attrs’s maintenance more sustainable!

Example

attrs gives you a class decorator and a way to declaratively define the attributes on that class:

>>> from attrs import asdict, define, make_class, Factory

>>> @define
... class SomeClass:
...     a_number: int = 42
...     list_of_numbers: list[int] = Factory(list)
...
...     def hard_math(self, another_number):
...         return self.a_number + sum(self.list_of_numbers) * another_number


>>> sc = SomeClass(1, [1, 2, 3])
>>> sc
SomeClass(a_number=1, list_of_numbers=[1, 2, 3])

>>> sc.hard_math(3)
19
>>> sc == SomeClass(1, [1, 2, 3])
True
>>> sc != SomeClass(2, [3, 2, 1])
True

>>> asdict(sc)
{'a_number': 1, 'list_of_numbers': [1, 2, 3]}

>>> SomeClass()
SomeClass(a_number=42, list_of_numbers=[])

>>> C = make_class("C", ["a", "b"])
>>> C("foo", "bar")
C(a='foo', b='bar')

After declaring your attributes, attrs gives you:

without writing dull boilerplate code again and again and without runtime performance penalties.

Hate type annotations!? No problem! Types are entirely optional with attrs. Simply assign attrs.field() to the attributes instead of annotating them with types.


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. The classic APIs (@attr.s, attr.ib, plus their serious-business aliases) and the attr package import name will remain indefinitely.

Please check out On The Core API Names for a more in-depth explanation.

Data Classes

On the tin, attrs might remind you of dataclasses (and indeed, dataclasses are a descendant of attrs). In practice it does a lot more and is more flexible. For instance it allows you to define special handling of NumPy arrays for equality checks, allows more ways to plug into the initialization process, and allows for stepping through the generated methods using a debugger.

For more details, please refer to our comparison page.

Project Information

attrs for Enterprise

Available as part of the Tidelift Subscription.

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. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.

Release Information

Changes


Full changelog