Created
April 26, 2024 01:02
-
-
Save mypy-play/8e3c55b817cd679d4e8c02a6eb30c4bd to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains 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 Dict, Iterator, TypeVar, Union | |
class A: | |
name: str = "" | |
K = TypeVar('K', bound=Union[str, A]) | |
def a(arg: Dict[K, int]) -> None: | |
d = dict( | |
(k.name if isinstance(k, A) else k, v) | |
for k, v in arg.items() | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment