Add `__class_getitem__` support to `ctypes.py_object`
Feature or enhancement
Proposal:
ctypes.py_object is 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 a TypeError at runtime:
>>> import ctypes >>> ctypes.py_object[int] Traceback (most recent call last): File "<python-input-1>", line 1, in <module> ctypes.py_object[int] ~~~~~~~~~~~~~~~~^^^^^ TypeError: type 'py_object' is not subscriptable
(albeit this is partially mitigated by deferred annotations in 3.14, but TypeError can 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 to ctypes.py_object so 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