Closed
Description
from typing import List
class Foo:
def keys(self) -> List[str]:
return ['a', 'b', 'c']
def __getitem__(self, key: str) -> str:
return f'value of {key}'
print(dict(Foo())) # {'a': 'value of a', 'b': 'value of b', 'c': 'value of c'}
works at runtime but fails type check
tkinter widgets are like this, they aren't Mapping
but they have .keys()
and __getitem__