Created
March 9, 2026 14:33
-
-
Save mypy-play/51cf4f57a12219fc53f4fd4f78a9fd16 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Protocol, TypedDict, Unpack, Any | |
| class Factory(Protocol): | |
| def __call__(self, **kwargs: Any) -> Any: | |
| pass | |
| def use_factory(factory: Factory): | |
| pass | |
| class MyParams(TypedDict): | |
| a: int | |
| class MyFactory(Protocol): | |
| def __call__(self, **kwargs: Unpack[MyParams]) -> Any: | |
| pass | |
| def mypy_fails(factory: MyFactory): | |
| use_factory(factory) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment