attrs
Classes Without Boilerplate
Decision gist · record as of 2026-08-14
Yes. attrs is a mature, zero-dependency library in the top 100 PyPI packages with no known vulnerabilities, active maintenance, and broad Python version support. It eliminates real boilerplate and is the de facto standard for declarative class definition in Python. Install it if you write classes regularly.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained with recent releases; supports Python 3.9 through 3.14 and both CPython and PyPy implementations.
License · maintenance · safety
MIT (permissive) — MIT license (permissive): you can use, modify, and distribute attrs freely in commercial and private projects with minimal restrictions.
last release 2026-03-19 (148 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 924,894,579 downloads/mo, #28 on PyPI
Alternatives
Verify before relying
from attrs import define, Factory
@define
class Example:
name: str
items: list = Factory(list)
obj = Example("test")
print(obj) # Example(name='test', items=[])- Whether the package's performance claims (no runtime penalties) have been benchmarked against dataclasses or manual implementations in recent versions.
- Specific details on how field transformers and validators interact with the initialization process beyond what the changelog excerpt describes.
What it is and what it does
attrs is a class-definition library that uses decorators and type annotations to declare attributes once, then automatically generates __init__, __repr__, __eq__, and other dunder methods. Instead of writing these methods by hand for every class, you annotate attributes and let attrs handle the boilerplate. It supports both modern type-annotation syntax and older field() declarations for projects that don't use types.
The library is widely used in production (including by NASA for Mars missions since 2020) and sits at the foundation of many Python projects. It offers more flexibility than the standard library's dataclasses—custom equality handling for NumPy arrays, multiple ways to hook into initialization, and debugger-friendly generated code. It has no runtime dependencies, installs as a pure Python wheel, and supports current Python versions (3.9+) on both CPython and PyPy.
Use it for
- Define data models or configuration classes without writing __init__ and __repr__ by hand.
- Build immutable or frozen classes with automatic equality and hashing.
- Create classes with factory defaults and custom validators for field values.
- Migrate from manual class boilerplate to declarative syntax while keeping full control over initialization hooks.
- Use in scientific or data-heavy projects where NumPy array comparison needs special handling.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
attrs is a mature, zero-dependency library in the top 100 PyPI packages with no known vulnerabilities, active maintenance, and broad Python version support. It eliminates real boilerplate and is the de facto standard for declarative class definition in Python. Install it if you write classes regularly.
Install
attrs on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent releases; supports Python 3.9 through 3.14 and both CPython and PyPy implementations.
Requires Python 3.9 or later.
License in practice
MIT license (permissive): you can use, modify, and distribute attrs freely in commercial and private projects with minimal restrictions.
Quickstart
from attrs import define, Factory
@define
class Example:
name: str
items: list = Factory(list)
obj = Example("test")
print(obj) # Example(name='test', items=[])
Verify before relying
- Whether the package's performance claims (no runtime penalties) have been benchmarked against dataclasses or manual implementations in recent versions.
- Specific details on how field transformers and validators interact with the initialization process beyond what the changelog excerpt describes.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 148 days since the last release |
| First released | |
| Downloads | 924,894,579 / month, #28 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTyping :: Typed |
Evidence: attrs-26.1.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “class boilerplate reduction”
- attrsattrs is a Python library that automatically generates common class…
- fastapi-restfulProvides utilities and base classes to reduce boilerplate when…
- django-annoyingProvides a collection of Django utility decorators and helper…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
A decorator that attaches metadata attributes to functions or classes without repeating boilerplate code.
Converts unstructured dictionaries into properly typed Python classes and back, with recursive validation support for attrs classes, dataclasses, and standard collection types.
Generates lightweight container classes with automatic `__repr__`, comparison methods, and field initialization from a fluent attribute-chain syntax, eliminating boilerplate for simple data holders.
No, not for new projects.
Desert generates marshmallow serialization schemas automatically from dataclasses and attrs classes, eliminating the need to write separate schema definitions.
However, proceed with caution: the package is abandoned and no longer maintained, so you should verify it works with your current dependency versions and be prepared…
Converts Python objects (dataclasses, attrs classes, and plain objects) to JSON-serializable dicts and strings, and deserializes them back to typed instances.
Install it if your project's Python version and dependencies are stable; avoid it if you need active maintenance or cutting-edge typing support.
Provides utility functions for working with Python class constructs and class-related patterns.
See also types-attrs · dataclass-factory · py-avro-schema · dataclass-wizard