➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 gvanrossum
收信人 Austin Bingham, christian.heimes, gvanrossum, mark.dickinson, rhettinger, robert_smallshire, serhiy.storchaka, tim.peters
日期 2020-10-04.19:16:05
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1601838965.92.0.774534057581.issue26680@roundup.psfhosted.org>
In-reply-to
内容
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.
历史
日期 用户 动作 参数
2020-10-04 19:16:05gvanrossum修改recipients: + gvanrossum, tim.peters, rhettinger, mark.dickinson, christian.heimes, serhiy.storchaka, robert_smallshire, Austin Bingham
2020-10-04 19:16:05gvanrossum修改messageid: <1601838965.92.0.774534057581.issue26680@roundup.psfhosted.org>
2020-10-04 19:16:05gvanrossum链接issue26680 messages
2020-10-04 19:16:05gvanrossum创建