attr
Simple decorator to set attributes of target function or class in a DRY way.
What it is and what it does
attr is a lightweight decorator for attaching metadata to Python functions and classes without repeating configuration code. It was designed to reduce boilerplate when setting Django admin field attributes like short_description and admin_order_field, allowing you to declare them once as decorator arguments instead of assigning them after function definition.
The package has been abandoned since 2022-07-13 and is now overshadowed by a more popular package that uses the same import name, creating namespace conflicts. With no runtime dependencies and a permissive MIT license, it installs cleanly, but its lack of maintenance and the naming collision make it a poor choice for new projects.
Use it for:
- Reduce repetition when setting Django admin metadata on calculated fields without separate assignment statements.
- Attach custom attributes to functions or classes using decorator syntax instead of post-definition assignment.
- Legacy Django projects that need minimal decorator support for metadata attachment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A decorator that attaches metadata attributes to functions or classes without repeating boilerplate code.
No. The package is abandoned (last release 2022-07-13, no commits since), and namespace shadowing issues are documented in its own description. For new projects, consider alternatives. For legacy code already using attr, migration is advisable to avoid import collision.
Install
attr on PyPI
pip
pip install attruv
uv add attrpoetry
poetry add attrInstalling attr
Before you install
Installation is frictionless with no runtime dependencies. However, the package is abandoned—last release was 2022-07-13 with no recent repository activity.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, suitable for both open and proprietary projects.
Quickstart
pip install attr
from attr import attr
@attr(short_description='Field', admin_order_field='real_field')
def my_calculated_field():
pass
A popular package named attrs now shadows this module's import name; the fact sheet recommends using the dry_attr alias instead to avoid conflicts.
Verify before relying
- Whether the namespace collision with the popular attrs package causes import or runtime issues in modern Python.
- Whether Python 2.7 support listed in classifiers remains functional or is purely historical.
- Current compatibility with modern Python versions given the 1493 days since last release.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,493 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 441,722/month — #6,642 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: attr-0.3.2-py2.py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
attrsattrs is a Python library that automatically…
permissive · top 100 on PyPI
django-annoyingProvides a collection of Django utility…
permissive · top 15,000 on PyPI
decopatchDecopatch simplifies writing decorators in…
permissive · top 5,000 on PyPI
attrdictProvides dictionary-like objects that allow…
permissive · top 5,000 on PyPI
fieldsGenerates lightweight container classes with…
permissive · top 15,000 on PyPI
dry-rest-permissionsDefines rules-based permissions for Django REST…
permissive · top 15,000 on PyPI
AutologgingAutologging provides decorators to…
permissive · top 15,000 on PyPI
django-widget-tweaksCustomize Django form field HTML and CSS in…
permissive · top 5,000 on PyPI
desertDesert generates marshmallow serialization…
permissive · top 15,000 on PyPI
icontracticontract enforces design-by-contract in Python…
permissive · top 15,000 on PyPI