attrs
Python classes without boilerplate — generate init, repr, equality, and more from declarative field definitions.
Repository Health
Technical Analysis
attrs is a mature, dependency-free Python library that brings back the joy of writing classes by removing the drudgery of implementing object protocols by hand. With a single class decorator and declarative field definitions, it generates initializers, string representations, equality and ordering methods, hashing, and slots — without runtime performance penalties.
Trusted in production across the ecosystem (and by NASA for Mars missions), attrs is the direct ancestor of the standard library’s dataclasses and remains far more flexible, offering validators, converters, custom setattr hooks, and deep customization of the generated code.
What You Get
- A class decorator (@define / @attr.s) that generates init, repr, eq, and optional ordering and hashing methods.
- Declarative field definitions via type annotations or field() calls, with defaults, factories, and keyword-only support.
- Built-in validators and converters to enforce and normalize attribute values at construction time.
- Memory-efficient slotted classes by default, plus frozen (immutable) class support.
- Helper functions like asdict, astuple, evolve, and fields for introspection and transformation.
- Full type-checker support with bundled stubs and py.typed, plus a stable classic API kept indefinitely.
Common Use Cases
- Modeling structured data and value objects without hand-writing initializers and comparison logic.
- Building immutable, frozen configuration or domain objects with validation on construction.
- Replacing verbose plain classes or extending beyond the limits of the standard dataclasses module.
- Normalizing and validating inputs automatically via converters and validators.
- Introspecting and transforming instances with asdict, astuple, and evolve for serialization or updates.
Under The Hood
Architecture - attrs is organized as two importable packages under src/: the classic attr namespace and the modern attrs namespace, which is a thin keyword-only facade (src/attr/_next_gen.py defines @define and field by partially applying the classic attrs/attrib with better defaults). The engine lives in src/attr/_make.py (~3,435 lines), which collects declared fields, builds Attribute descriptors, and dynamically compiles init, repr, eq, hash, and setattr logic by generating source code and exec-ing it for near-hand-written speed. Supporting concerns are cleanly separated into focused modules: _funcs.py (asdict/astuple/evolve), validators.py, converters.py, setters.py, filters.py, _cmp.py, and exceptions.py.
Tech Stack - Pure Python (99.9% of the codebase) with zero runtime dependencies, supporting CPython and PyPy across Python 3.9 through 3.15. It builds with Hatchling plus hatch-vcs for VCS-derived versioning and hatch-fancy-pypi-readme. Development tooling is modern: uv for locking (uv.lock), Ruff for lint/format, tox for the test matrix, and Sphinx with the Furo theme and towncrier changelog fragments for docs. Types ship as inline .pyi stubs alongside py.typed markers in both packages.
Code Quality - Quality is exemplary. The tests/ directory holds 31 test modules covering make, next-gen APIs, validators, converters, slots, setattr, pattern matching, annotations, pickling compatibility, and packaging, and the suite uses Hypothesis for property-based testing plus pytest-xdist for parallelism and pytest-codspeed for benchmark regressions. Static-analysis conformance is verified against mypy, pyright, ty, and pyrefly. Naming is consistent, public and private modules are clearly delineated by underscore convention, and errors surface through a dedicated exceptions module rather than generic raises.
API Design - The public API is deliberately ergonomic and minimal: @define with field() gives a zero-boilerplate path, type annotations are fully optional, and everything is keyword-only in the modern API to prevent argument-order mistakes. Getting started requires only a decorator and attribute declarations. Documentation is thorough (a full Sphinx site at attrs.org, an extensive changelog, comparison and API-naming guides), and the project intentionally preserves the classic @attr.s API indefinitely so upgrades never break existing code.
Used by 22 apps in this directory
superglue
AI Agents · Data Engineering · Developer Tools
superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).
Svix
Automation · Developer Tools
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.
SWIRL
Data Engineering · Databases · Search
Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.
Taiga Back
Developer Tools · Project Management
Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.