skillfed

abstractcp

Create abstract class variables

abstractcp v1.0.0 76.6K downloads/30d#14,614 on PyPI9
Permissive license AGING released

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 abstractcp

uv

uv add abstractcp

poetry

poetry add abstractcp

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

abstract class properties pythonabstract class variablesenforce class configurationabstract class constantsclass property inheritance
abstract-classestype-hintsclass-properties

More Software Development packages