-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adding descriptor methods to _SimpleCData #11272
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
Conversation
This allows adding type annotations to structures and unions that resolve to the underlying types when accessed inside structures
This comment has been minimized.
This comment has been minimized.
… feedback from reviewers/maintainers
This comment has been minimized.
This comment has been minimized.
I've checked out the problem from
The offending line returns
When the interpreter returns edit: clarified last part, was tired when I wrote it, still am |
See the test_cases/stdlib directory for examples on how to write tests. Basically, use |
This comment has been minimized.
This comment has been minimized.
It turns out that subclassing the basic types causes them to not be unboxed, and this behaviour has always been part of ctypes. I added |
Diff from mypy_primer, showing the effect of this PR on open source code: comtypes (https://github.com/enthought/comtypes)
+ comtypes/typeinfo.py:452: error: Incompatible return value type (got "tuple[str, int | None]", expected "tuple[str, tagFUNCDESC | tagVARDESC | ITypeComp] | None") [return-value]
|
This allows adding type annotations to structures and unions that resolve to the underlying types when accessed inside structures.
I don't know how to make proper tests for this, so I've made some examples where I've marked the lines that are expected to fail typechecking.