-
Notifications
You must be signed in to change notification settings - Fork 22
Generate stubs #156
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
Generate stubs #156
Conversation
5646055 to
e03358d
Compare
|
#150 has some (mostly orthogonal) work. A few of the problems I faced:
|
|
I don't think there's an issue with the changes to the cmakefile. The proposed solution works locally, i.e. the stubs work as expected. (Linux, py3.13) I was not able to resolve the issue with the wheels CI for one of the MacOS-13 CI arches. |
025a936 to
34c02f6
Compare
34c02f6 to
520789f
Compare
|
@inducer: What do you think of this? |
|
Since #150 also includes some similar bits, feel free to close this and continue with that. One thing I learned during this experiment was that making it work for certain arches of macos inside |
inducer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few questions below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a generated file, why is it being added to git?
| # {{{ Generate stubs (.pyi files) | ||
|
|
||
| # Pass -DREBUILD_STUBS to regenerate the stubs. | ||
| if(REBUILD_STUBS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do this all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These stubs look a lot better than what my attempt (#150) produced. Yay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is typing, e.g. islpy._isl.BasicSet. Are the type checkers smart enough to see that as the same type as islpy.BasicSet? What is the canonical name that's shown in error messages? If it's the wrong one, is there a way to fix it? (Could this be called __init__.pyi?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__.py adds methods to the types from _isl. My understanding is that type checkers will consider either __init__.py or __init__.pyi, but not both. Is there a path for the type checker to know about both the C++ and the Python-implemented bits? One kind-of-hacky way would be to write AST-based code to patch in the stubs from __init__.py.
nanobind_add_stubis a convenient routine, just used that.