A stricter Protocol enforcement for Python
Project description
StrictProtocol
StrictProtocol is a lightweight runtime validation layer for Python's Protocol, enforcing exact method signature conformance at class definition time.
🔍 Features
- Enforces method existence and signature compliance for protocol implementations
- Catches missing or mismatched methods early—at class creation
- Drop-in compatible with
typing.Protocol
🚀 Example
from typing import Protocol
from strictprotocol import StrictProtocol
class Greeter(Protocol):
def greet(self, name: str) -> str: ...
class MyGreeter(StrictProtocol, Greeter):
def greet(self, name: str) -> str:
return f"Hello, {name}"
📦 Installation
pip install strictprotocol
🧪 Testing
To run tests:
pytest tests/
📄 License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
strictprotocol-0.1.5.tar.gz
(11.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strictprotocol-0.1.5.tar.gz.
File metadata
- Download URL: strictprotocol-0.1.5.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a46d63968cbbbc02f834d7664b0acfd02cf524c9baba11b6056e539d5b6c2ba
|
|
| MD5 |
f338f51f17179a4efc3f717cf60b06ce
|
|
| BLAKE2b-256 |
8de2fc72e4fe55b675e25c694db67f92801029e85a33d861a609af835f6323c2
|
File details
Details for the file strictprotocol-0.1.5-py3-none-any.whl.
File metadata
- Download URL: strictprotocol-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56135a4923bb534d2b97adef0a88b31e24e5c9682200e13167972c7e262ac1f7
|
|
| MD5 |
d1899870371646870b64fdc20cc5ccbb
|
|
| BLAKE2b-256 |
b164dba4903c98915bb7ada34f298ff8b533e03fe0a91acc24b3ad3346fab27d
|