attrs

Python classes without boilerplate — generate init, repr, equality, and more from declarative field definitions.

Library
PyPI
v26.1.0
5,830stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
84/100Excellent
Development Activity100
Maintenance72
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
89/100Excellent
Architecture90
Code Quality95
Innovation92
Learning Curve80

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

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
100%
Apache 2.0

ClearML

Devops · Automation

6,827

Auto-magical MLOps platform that tracks experiments, versions data, orchestrates pipelines, and serves models with just two lines of code.

View details
94
Repo Health
79
Technical
69
Dependency
Built with
Python100%
Updated yesterday
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
PLpgSQL
97%
Apache 2.0

DataLens

Analytics

1,696

Open-source business intelligence platform with drag-and-drop dashboards, multi-source SQL connectors, and Kubernetes-ready deployment built by Yandex.

View details
70
Repo Health
71
Technical
80
Dependency
Built with
PLpgSQL97%
Updated 3 weeks ago
C++
74%
Other

Dragonfly

Databases · Developer Tools · Devops

31,013

A modern Redis and Memcached replacement engineered for multi-core servers — delivering 25x more throughput, better cache hit rates, and up to 80% lower memory consumption with full API compatibility.

View details
90
Repo Health
9
Technical
71
Dependency
Built with
C++74%
Python16%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,138

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript97%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search