You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy is also not happy with Array(...) but for other reasons:
out/ex.py:4: error: Array constructor argument 1 of type "c_int" is not convertible to the array element type <nothing>
out/ex.py:4: note: Revealed type is "ctypes.Array[<nothing>]"
I don't think there is a good way to make Array abstract in typeshed. As it doesn't derive from abc.ABCMeta at runtime, we shouldn't derive it either. If you have an idea on how to mark it, please open a PR. Until then I'm closing this as "inexpressable".
This way, we would have a class with "abtract" attributes and it won't be possible to create instances of it.
It would be also helpful for subclassing like
Activity
JelleZijlstra commentedon Nov 20, 2021
Note that mypy has a dedicated plugin for ctypes (https://github.com/python/mypy/blob/master/mypy/plugins/ctypes.py), so not everything here may be fixable in typeshed.
srittau commentedon Nov 22, 2021
I don't think there is a good way to make
Arrayabstract in typeshed. As it doesn't derive fromabc.ABCMetaat runtime, we shouldn't derive it either. If you have an idea on how to mark it, please open a PR. Until then I'm closing this as "inexpressable".sobolevn commentedon Nov 22, 2021
We can try to make
_length_and_type_abstract properties: https://github.com/python/cpython/blob/main/Modules/_ctypes/_ctypes.c#L1522-L1526Docs: https://github.com/python/cpython/blob/1cbaa505d007e11c4a1f0d2073d72b6c02c7147c/Doc/library/ctypes.rst#arrays-and-pointers
This way, we would have a class with "abtract" attributes and it won't be possible to create instances of it.
It would be also helpful for subclassing like
sobolevn commentedon Nov 22, 2021
But, they should be writable:
sobolevn commentedon Nov 23, 2021
Refs #6348