jaraco.classes

Utility functions for working with Python class constructs.

Library
PyPI
v3.4.0
11stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
32/100Needs Attention
Development Activity12
Maintenance20
Community24
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality85
Innovation72
Learning Curve80

jaraco.classes is a small, focused Python library that collects reusable utilities for working with class constructs. It provides helpers such as class-level properties, non-data properties, metaclasses that track subclasses, and routines for inspecting a class’s ancestry.

Widely depended upon across the Python packaging ecosystem (it is a transitive dependency of tools like keyring), the library is fully typed and thoroughly documented with doctests. It stays intentionally tiny, giving developers well-tested building blocks for descriptor and metaclass patterns without pulling in heavy dependencies.

What You Get

  • Class-level property descriptors, including classproperty and a resettable NonDataProperty
  • Metaclasses such as LeafClassesMeta that automatically track subclasses
  • Ancestry helpers to list all base classes and class names of an object
  • A fully typed, doctested API with a py.typed marker for static type checkers

Common Use Cases

  • Adding computed properties that work at the class level rather than the instance level
  • Building registries of subclasses via a tracking metaclass
  • Introspecting an object’s class hierarchy for serialization or plugin discovery

Under The Hood

Architecture - The package is organized under the jaraco.classes namespace with three focused modules: properties.py (descriptor implementations like NonDataProperty and classproperty), meta.py (metaclasses such as LeafClassesMeta that hook init to track subclasses), and ancestry.py (functions like all_bases and all_classes built on the MRO). Each module is independent and imported directly.

Tech Stack - Pure Python targeting 3.10+, built with setuptools plus setuptools_scm for versioning. Its single runtime dependency is more-itertools (used for unique_everseen in ancestry). It uses modern typing features including TypeVar, Generic, overload, and Protocol under TYPE_CHECKING guards.

Code Quality - Code is fully type-annotated and ships a py.typed marker; correctness is documented and exercised through extensive doctests embedded in each module. Tooling includes pytest, ruff, mypy (mypy.ini), and towncrier for changelog management, following the maintainer’s shared skeleton project layout.

API Design - The surface area is deliberately small and discoverable: import the descriptor or metaclass you need and apply it directly. Doctests double as usage examples, and the fully typed signatures give editors and type checkers precise information, keeping the learning curve low for anyone familiar with Python descriptors.

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