Message377972
Possibly at some point in the future we can switch to using typing.Protocol, which requires neither registration nor explicit subclassing (it's like Hashable). This makes it easy for user code to define custom protocols as needed. So if you need something that has .keys() and .items() but you don't care about .values() you can just write
class KeysAndItems(typing.Protocol):
def keys(self): ...
def items(self): ...
def my_func(x: KeysAndItems):
...
This can be statically checked using e.g. mypy. |
|
Date |
User |
Action |
Args |
2020-10-04 19:16:05 | gvanrossum | set | recipients:
+ gvanrossum, tim.peters, rhettinger, mark.dickinson, christian.heimes, serhiy.storchaka, robert_smallshire, Austin Bingham |
2020-10-04 19:16:05 | gvanrossum | set | messageid: <1601838965.92.0.774534057581.issue26680@roundup.psfhosted.org> |
2020-10-04 19:16:05 | gvanrossum | link | issue26680 messages |
2020-10-04 19:16:05 | gvanrossum | create | |
|