strict-abc
strict-abc provides StrictABCMeta and StrictABC, which validate concrete
implementations of abstract methods at class definition time.
The goal is to fail fast when a subclass violates LSP-friendly signature rules.
Installation
pip install strict-abc-lsp
Usage
from abc import abstractmethod
from strict_abc import StrictABC
class BaseService(StrictABC):
@abstractmethod
def process(self, data: dict, cache: bool = True) -> str:
...
class ValidService(BaseService):
def process(self, data: dict, cache: bool = True) -> str:
return "ok"
This works.
But this raises TypeError at class definition time:
class InvalidService(BaseService):
def process(self, data: dict, cache: bool) -> str:
return "ok"
Because removing a default value strengthens the precondition.
Options
Configure validation with __strict_options__:
class Base(StrictABC):
__strict_options__ = {
"check_names": True,
"check_defaults": True,
"check_types": True,
"check_return_type": True,
}
@abstractmethod
def fetch(self, url: str) -> bytes:
...
Default options:
{
"check_names": False,
"check_defaults": True,
"check_types": False,
"check_return_type": False,
}
Development
Install dependencies:
make install
Run lint, type check, tests, build and dist check:
make all
Install pre-commit hooks:
make pre-commit-install
Run tests with coverage:
make cov
Publishing
For TestPyPI:
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi <YOUR_TESTPYPI_TOKEN>
make publish-test
For PyPI:
poetry config pypi-token.pypi <YOUR_PYPI_TOKEN>
make publish
License
MIT
Metadata
Release files for strict-abc-lsp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| strict_abc_lsp-0.2.0.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| strict_abc_lsp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / strict_abc_lsp-0.2.0.tar.gz
| Download URL | strict_abc_lsp-0.2.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9828314f58c42c677c13a17349d8baaccd3797feec83e41ea86738ddaa037989
|
|
BLAKE2b-256 checksum How to use checksums |
9045ac472f8dc8714f8990f5089727c857fa53d80c2ff08706cdc461fcbc6245
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.14.2 Darwin/25.5.0
|
Release files / strict_abc_lsp-0.2.0-py3-none-any.whl
| Download URL | strict_abc_lsp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cdc8e55f513eb44f1c6edfaf0bf6de3b18c8019abb7cecd73f4d42b1aa964b9
|
|
BLAKE2b-256 checksum How to use checksums |
3b41cba0556c4ff9426784c3b3609b3cad1e46a91217c300b37c47ceb09651ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.14.2 Darwin/25.5.0
|