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.2.tar.gz
(10.7 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.2.tar.gz.
File metadata
- Download URL: strictprotocol-0.1.2.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e56620e4142c8dd4b35296c1dea2ec55bbebd2ee71b0de26295b4e367875b0d
|
|
| MD5 |
4d2cda57263d809d7431e7a158d8945f
|
|
| BLAKE2b-256 |
3ae2f6f5c1a49a47a2bff5e5b328198fbca547c5e7b21dda760abb6b54b1efda
|
File details
Details for the file strictprotocol-0.1.2-py3-none-any.whl.
File metadata
- Download URL: strictprotocol-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.4 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 |
176c1ee1d37f0ad1db070883e78373fd0347a82ae14bc2c6af044f3bfdeb86db
|
|
| MD5 |
0a09e2dfc92f2f3cc8e2f2ae3da11851
|
|
| BLAKE2b-256 |
f9266ffa80b7dfb644dc8646846a658343d70618624e7e80627a3cfb054e397b
|