Registry / devops / abstractcp

abstractcp

JSON →
library1.0.0pypypi✓ verified 79d ago

A Python library (v1.0.0, stable) that provides a decorator to create abstract class variables (class-level attributes) with support for inheritance checks. Requires Python >=3.8.

pip install abstractcp
INSTALL
IMPORT
SIG · ABSTRACTCP
A
abstractcp
devopspythonv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Abstract
from abstractcp import Abstract
from abstractcp import abstract_classvar
abstract_class_property
from abstractcp import abstract_class_property
AbstractClassWithoutAbstractPropertiesWarning
from abstractcp import AbstractClassWithoutAbstractPropertiesWarning

Define abstract class variables that must be overridden in subclasses.

from abstractcp import abstract_classvar from abc import ABC class MyBase(ABC): x = abstract_classvar(int) class MyConcrete(MyBase): x = 10 # Attempting to instantiate MyBase without setting x raises TypeError # obj = MyBase() # TypeError: Can't instantiate abstract class MyBase with abstract class variables x
Debug
Known issues
gotchaabstract_classvar only works with classes inheriting from ABC. Using it on a non-ABC class will not enforce overriding.
fix
Ensure your base class inherits from abc.ABC.
affects: all
gotchaAbstract class variables must be assigned exactly the same type as declared (or a subtype). Mismatched types raise TypeError at instantiation.
fix
Double-check the type hint when declaring abstract_classvar.
affects: all
Upgrade
Version history
1.0.0latest on PyPI · released May 20, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
abstractcp — pip install abstractcp · libregistry