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.9.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.9.tar.gz.
File metadata
- Download URL: strictprotocol-0.1.9.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 |
9c5be3ec02805317da0b4e8603b4d2a7d1745a1973086c51f5f0f7093747002a
|
|
| MD5 |
a54158ec8a40596e7b017657bb17e5a4
|
|
| BLAKE2b-256 |
649437b01849dd8a9bf9b21d5cafce6eced61827d32c187100346d9bee368c91
|
File details
Details for the file strictprotocol-0.1.9-py3-none-any.whl.
File metadata
- Download URL: strictprotocol-0.1.9-py3-none-any.whl
- Upload date:
- Size: 10.5 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 |
072eb0de9d805a23759e2bb1ae60a947bcadb9b1eb3212ab3de83686894e15f0
|
|
| MD5 |
c288e0884c022d5a393c05927e322c9f
|
|
| BLAKE2b-256 |
1352c34e917ad21f049c064b817d373864ee14e5d2c0c5143c8cf7be2c41fa2f
|