Created
February 12, 2026 15:06
-
-
Save mypy-play/8f3bc3a64783a873c24dcc51b59deab1 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 Callable, TypeVar | |
| _K = TypeVar("_K") | |
| _V = TypeVar("_V") | |
| class Foo: | |
| pass | |
| class Util: | |
| @staticmethod | |
| def apply(i: str, g: Callable[[str], _K]) -> _K: | |
| return g(i) | |
| @staticmethod | |
| def constructor(_: dict[_K, _V]) -> Foo: | |
| return Foo() | |
| def proof_of_concept( | |
| f: Callable[[int], str], | |
| ) -> None: | |
| Util.constructor( | |
| { | |
| f("foo"): f("not_int") | |
| } | |
| | Util.apply( | |
| "", lambda _: {} | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment