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.12.tar.gz
(11.5 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.12.tar.gz.
File metadata
- Download URL: strictprotocol-0.1.12.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30a65952015bd3bb6e510464d0eccf1acf6b476bb703cf6aa593e03d5cd3aff4
|
|
| MD5 |
50938db9b180296ca90bc8ca3358a1db
|
|
| BLAKE2b-256 |
1b403d97d4d3b2653ff37a20bddaf5fca5c13d77448c78f528d07dc6db94a13b
|
File details
Details for the file strictprotocol-0.1.12-py3-none-any.whl.
File metadata
- Download URL: strictprotocol-0.1.12-py3-none-any.whl
- Upload date:
- Size: 10.8 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 |
a84cbe51ad8f598761c25c84dfa3e029ae2496035e40e256d445e199c005ce5b
|
|
| MD5 |
9ef791bbfd0207a4fce06d40d3264c83
|
|
| BLAKE2b-256 |
9a491c55ac3cb83211c62db4abb87837c64589c7ed6722a324d3da54cd5e9e13
|