fromtypingimportListclassFoo:
defkeys(self) ->List[str]:
return ['a', 'b', 'c']
def__getitem__(self, key: str) ->str:
returnf'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__
works at runtime but fails type check
tkinter widgets are like this, they aren't
Mappingbut they have.keys()and__getitem__