abstractcp
Create abstract class variables
What it is and what it does
AbstractCP provides a way to define abstract class properties—class-level configuration that subclasses must explicitly set—with support for Python's type hints and static type checkers like mypy. You inherit from the `Abstract` base class and mark required class properties using `abstract_class_property(type)`, which enforces that concrete subclasses provide a value and raises a `TypeError` if they don't. This solves a gap in Python's standard `abc` module, which has no built-in mechanism for abstract class variables.
The package is designed to be lightweight and Pythonic: it does all validation at class definition time (no runtime overhead), integrates cleanly with type hints, and produces clear error messages when a subclass forgets to define a required property. It supports multi-level inheritance—an abstract class can have abstract children—and works with Python 3.8 and higher.
Use it for:
- Define a base parser class with an abstract PATTERN property that each parser subclass must set before use.
- Create a base array/tensor class that requires subclasses to declare their DIMENSIONS as a class constant.
- Enforce that configuration subclasses define required settings (e.g., API endpoint, database URL) at class definition time.
- Build plugin systems where each plugin subclass must declare its name, version, or handler type.
- Ensure type-safe class hierarchies where mypy validates that abstract properties are satisfied before instantiation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Allows you to define abstract class properties that subclasses must implement, enforcing required configuration at class definition time with static type-checker support.
Yes, if you need to enforce required class-level configuration in inheritance hierarchies and want static type-checker support. The package is small, has no dependencies, and solves a real gap in Python's standard library. The aging maintenance status is not a blocker for a stable, narrow-scope tool, but verify that the pattern fits your use case—it is not a general-purpose utility.
Install
abstractcp on PyPI
pip
pip install abstractcpuv
uv add abstractcppoetry
poetry add abstractcpInstalling abstractcp
Before you install
Low install friction; pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 2024-05-20 and last commit 2026-01-04, with minimal repository activity (9 stars), but no active issues reported.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute freely provided you include the license notice.
Quickstart
pip install abstractcp
import abstractcp as acp
class Parser(acp.Abstract):
PATTERN: str = acp.abstract_class_property(str)
class MyParser(Parser):
PATTERN = r"my_pattern"
# Attempting to instantiate Parser directly or a subclass without PATTERN raises TypeError
Requires Python 3.8 or higher; abstract properties must be defined in classes that inherit directly from acp.Abstract.
Verify before relying
- Whether the package is actively maintained or in maintenance-only mode given the aging status and sparse commit history.
- Real-world adoption patterns beyond the stated download count to assess whether the pattern it solves is widely needed.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 816 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 76,571/month — #14,614 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: abstractcp-1.0.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
docstring-inheritanceAutomatically inherits docstrings from parent…
permissive · top 15,000 on PyPI
python-interfaceDeclares interfaces and statically asserts that…
permissive · top 15,000 on PyPI
flake8-class-attributes-orderA flake8 extension that enforces a configurable…
permissive · top 15,000 on PyPI
xarray-dataclassDefines typed xarray DataArray and Dataset…
permissive · top 15,000 on PyPI
async-propertyProvides Python decorators (@async_property and…
permissive · top 5,000 on PyPI
resolvelibResolveLib provides a generic dependency…
permissive · top 1,000 on PyPI
type-enforcedEnforces Python type annotations at runtime…
permissive · top 15,000 on PyPI
property-managerProvides custom Python property decorators for…
permissive · top 15,000 on PyPI
useful-typesProvides reusable type protocols and aliases…
unclear · top 15,000 on PyPI