Python's structural subtyping allows any object, including a module, to satisfy a Protocol.
This repository tests this specific feature. We define a simple protocol and a module with a function that matches the protocol's signature. We then attempt to use this module where an object conforming to the protocol is expected.
- src/example_module_protocols/behavior.py: Defines the Proto protocol.
- src/example_module_protocols/implementations/bar.py: A simple module that acts as an implicit implementation of Proto.
- src/example_module_protocols/main.py: The main script that consumes the bar module.
- run_type_checkers.sh: A convenience script to run Mypy, Pyright, Pyrefly, and Ty, making it easy to compare their outputs.
- uv
uv sync --frozen
source .venv/bin/activate
./run_type_checkers.sh