ihoop
Strict, immutable Abstract/Final classes
Do you like python, but wish it is was more like Julia? Do like Julia, but wish it was a language other people used? Did you read Design Patterns: Elements of Reusable Object-Oriented Software, but wish you didn't?
Meet ihoop: a tiny library that turns plain Python classes into frozen, Abstract/Final instances. Drop in Strict as a base class and get:
- Immutability by default: once
__init__finishes, your objects are read-only. - Abstract or Final:
- Abstract classes: can be subclassed, but cannot be instantiated.
- Concrete classes: can be instantiated, but cannot be subclassed.
- Abstract attributes, not just methods: Declare with
AbstractAttribute[T]; subclasses must supply (via type hints) a real value. - Abstract class variables: Declare with
AbstractClassVar[T]; subclasses must supply a value, which becomes immutable. - No dependencies: pure Python.
This package was largely copied inspired by equinox's strict=True flag. For more information see https://docs.kidger.site/equinox/pattern/.
Why is it called ihoop? Because (i) (h)ate (o)bject (o)riented (p)rogramming 😉
Example
from ihoop import Strict, AbstractAttribute, AbstractClassVar
class AbstractAnimal(Strict):
name: AbstractAttribute[str]
species: AbstractClassVar[str]
class Dog(AbstractAnimal):
name: str
species = "Canis familiaris"
def __init__(self, name: str):
self.name = name
>>> Dog("Fido").name
'Fido'
>>> Dog.species
'Canis familiaris'
>>> d = Dog("Rex")
>>> d.name = "Max" # Instance attributes are immutable
AttributeError: Cannot set attribute 'name' on frozen instance of Dog. strict objects are immutable after initialization.
>>> Dog.species = "Something else" # Class variables are also immutable once resolved
AttributeError: Cannot set frozen class variable 'species' on class 'Dog'. Class variables resolved from abstract requirements are immutable.
Sharp Edges
- It is important to type hint all member variables at the class level. It is very possible to bypass the checking/enforcement of
Strictby doing things in the__init__.
Roadmap
- dataclass testing and integration
- abstractclassvar: strictness for class variables
- Package for pypi
- ?
Metadata
Release files for ihoop 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ihoop-0.1.4.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ihoop-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.1 kB
Release files / ihoop-0.1.4.tar.gz
| Download URL | ihoop-0.1.4.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f50bdf3d89f755b2005369e23d2927eb28b16a7135a1931d2012ff36cd148a66
|
|
BLAKE2b-256 checksum How to use checksums |
1af111df2786a50e9a70daa472c2bfbfe5ac985365f3f4c0b958ce18b91ee99c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logRelease files / ihoop-0.1.4-py3-none-any.whl
| Download URL | ihoop-0.1.4-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceb19de4bf0e9707cd969e95072a3fa3a6807794681627ab348eb7de31d7caa2
|
|
BLAKE2b-256 checksum How to use checksums |
c8621fa732bac14aa3e732cd6a2cd75828eb0e584e6eecdb5aa09b7974e6ad8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency log