Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
I was updating my CI to support python3.12 and ran into the following error that isn't present in the 3.12 buildshttps://github.com/Gobot1234/steam.py/actions/runs/7276342755/job/19825996032
MRE:
fromenumimportIntEnumfromtypingimportProtocolclassclassproperty:def__init__(self,func):self.__func__=funcdef__get__(self,instance,type):returnself.__func__(type)class_CommentThreadType(IntEnum):WorkshopAccountDeveloper=2classCommentable(Protocol):@classpropertydef_COMMENTABLE_TYPE(cls):return_CommentThreadType[cls.__name__]
Traceback onmain:
Running Debug|x64 interpreter...Traceback (most recent call last): File"C:\Users\alexw\coding\test_protocol.py", line14, in<module>classCommentable(Protocol):...<2 lines>...return _CommentThreadType[cls.__name__] File"C:\Users\alexw\coding\cpython\Lib\typing.py", line1838, in__init__cls.__callable_proto_members_only__=all(~~~^callable(getattr(cls, attr,None))for attrincls.__protocol_attrs__^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ )^ File"C:\Users\alexw\coding\cpython\Lib\typing.py", line1839, in<genexpr>callable(getattr(cls, attr,None))for attrincls.__protocol_attrs__~~~~~~~^^^^^^^^^^^^^^^^^ File"C:\Users\alexw\coding\test_protocol.py", line9, in__get__returnself.__func__(type)~~~~~~~~~~~~~^^^^^^ File"C:\Users\alexw\coding\test_protocol.py", line17, in_COMMENTABLE_TYPEreturn _CommentThreadType[cls.__name__]~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File"C:\Users\alexw\coding\cpython\Lib\enum.py", line763, in__getitem__returncls._member_map_[name]~~~~~~~~~~~~~~~~^^^^^^KeyError:'Commentable'
Should typing be more careful about accessing random attributes on classes to prevent these kinds of errors in the future?
CPython versions tested on:
3.12
Operating systems tested on:
macOS