-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add __class_getitem__ support to ctypes.py_object #132168
Copy link
Copy link
Closed
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestopic-typingtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestopic-typingtype-featureA feature request or enhancementA feature request or enhancement
Projects
- StatusShow more project fieldsDone
Feature or enhancement
Proposal:
ctypes.py_objectis generic in typeshed, but is not subscriptable at runtime. This can be troublesome for end users, since type checkers will prompt them to supply a generic type argument, but doing so will produce aTypeErrorat runtime:(albeit this is partially mitigated by deferred annotations in 3.14, but
TypeErrorcan still pop up if the annotations are ever evaluated)py_object's typeshed stubs have been stable for a while, and it seems unlikely to be made non-generic in the future. Therefore I propose that__class_getitem__be added toctypes.py_objectso that it can be subscripted at runtime.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
python/typeshed#13760
Linked PRs
__class_getitem__toctypes.py_object#132169