Add __class_getitem__
support to ctypes.py_object
#132168
Labels
extension-modules
C modules in the Modules dir
topic-ctypes
topic-typing
type-feature
A feature request or enhancement
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 aTypeError
at runtime:(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 toctypes.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
Links to previous discussion of this feature:
python/typeshed#13760
Linked PRs
__class_getitem__
toctypes.py_object
#132169The text was updated successfully, but these errors were encountered: