Skip to main content

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


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.8.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strictprotocol-0.1.8-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file strictprotocol-0.1.8.tar.gz.

File metadata

  • Download URL: strictprotocol-0.1.8.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

Hashes for strictprotocol-0.1.8.tar.gz
Algorithm Hash digest
SHA256 28f3d656a313008f22080ae81d88a8735e19dc50051af6d2fc446d61004fed15
MD5 f7ac1ecb93c703168231e4b51fbdddb9
BLAKE2b-256 3785bc54f3d9bc9f38ee5b67f992ae0e09e3a8a019e74f763f8a7c1cfaa62906

See more details on using hashes here.

File details

Details for the file strictprotocol-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: strictprotocol-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for strictprotocol-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 42d841d6c2c58ad2ceb72cb7d4eee05fa0445e9279385214ab1984821d220683
MD5 7392c104ccabd72fcd379b539c578198
BLAKE2b-256 27836e0e17bb123c1eecfaaf4b63daea0810ab451d0c61fcc80b926e85ba03e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page