Created
February 12, 2026 14:56
-
-
Save mypy-play/84b167c9a3f36ee0672ee4379a09be8b 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