Created
February 12, 2026 14:50
-
-
Save mypy-play/0a9d48b8338d2769ce48f29fd2dc951a 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( | |
| { | |
| "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