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.3.tar.gz
(11.4 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.3.tar.gz.
File metadata
- Download URL: strictprotocol-0.1.3.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97b149a803686392419103f320b797e4046b759f016128a1c58990c1531c262
|
|
| MD5 |
fc54f91b0924e666626c3d0f5af0a0e0
|
|
| BLAKE2b-256 |
6932a0d8de68bdab2b9ef34e03fff68dd6c9ea64c67899980cd0164786bcaf5a
|
File details
Details for the file strictprotocol-0.1.3-py3-none-any.whl.
File metadata
- Download URL: strictprotocol-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.0 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 |
8c5a5206b0d34ecec2fc60f23a0c6d42502791d4d4afb3821726a30915789ad4
|
|
| MD5 |
61965e50c4ac547d8856506d5df9611e
|
|
| BLAKE2b-256 |
a9e384efe7a8e56da3915b91ead18cf0296b8f777ba1d3263631b5828513ac66
|