Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created November 10, 2025 22:22
Show Gist options
  • Save mypy-play/d2db12a78c27d6dd5e95067459eea79c to your computer and use it in GitHub Desktop.
Save mypy-play/d2db12a78c27d6dd5e95067459eea79c to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from __future__ import annotations
from typing import TypeVar
VALUES: dict[str, str] = {"SIZE": "100", "ADDR": "0x100", "NAME": "potato"}
T = TypeVar("T", bound=str | int)
def get_parameter(parameter: str, _rtype: type[T]) -> T:
"""Get the parameter"""
if parameter == "SIZE":
return 5
return "potato"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment