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.1.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.1.0.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| strict_abc_lsp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / strict_abc_lsp-0.1.0.tar.gz
| Download URL | strict_abc_lsp-0.1.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b7218def7d21378687314291d98bfa3afd28263821e8aac7f088323af6dc999
|
|
BLAKE2b-256 checksum How to use checksums |
bef93fc82c5862b7f5d04137ac50503899a2b23c6a213406f0786bbb7f4778e6
|
| 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.1.0-py3-none-any.whl
| Download URL | strict_abc_lsp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b68f5e87ea4cc474b78b6d70071fc41c563e874ca34429ed8b556a52fc7065b
|
|
BLAKE2b-256 checksum How to use checksums |
b797eb62e580e6a141092d1ba0dfbd10b621442a5658501d395178417e59c311
|
| 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
|