-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ctypes.Array
should be abstract
#6349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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. |
I don't think there is a good way to make |
We can try to make This way, we would have a class with "abtract" attributes and it won't be possible to create instances of it. class X(object, Array):
_length_ = 5
_type_ = "i" |
But, they should be writable: >>> from ctypes import c_int
>>> x = c_int * 3
>>> x
<class '__main__.c_int_Array_3'>
>>> x._length_
3
>>> x._length_ = 2
>>> x._type_ = 'a' |
Refs #6348 |
Right now
Array
inctypes
is a regular class:typeshed/stdlib/ctypes/__init__.pyi
Lines 269 to 271 in 5c8e68f
But, in reallity - you cannot instantiate it:
Mypy is also not happy with
Array(...)
but for other reasons:Array(...)
is not tested in https://github.com/python/mypy/blob/master/test-data/unit/check-ctypes.test at allThe text was updated successfully, but these errors were encountered: