Repository navigation
Conversation
Contributor
Author
|
Closing this because I actually think the "trim imports" feature is doing this correctly already, I was just holding it wrong. And the post-trimming as already implemented doesn't have the downside of requiring user changes as this does. Sorry for the noise ;) Thanks for the great project! |
Owner
|
No worries! Thank you for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current behavior of
stubgen-pyxis to convertcimports toimports and include them in the.pyifile. The problem we are running into with this behavior is that most of what iscimported is not actually Python-exposed content, such ascdef structorcdeffunctions etc. When these get included in the.pyifile and then we try to check for type annotation consistency usingpyrightormypy, these imports fail (since they point to things that aren't Python importable and can't be re-exposed publicly). For our project, we would like to eventually get to something that is type check error-free, and this makes that challenging.I realize this is a bit of a grey area for Cython. It is possible to
cimportan extension type, which /is/ runtime imported and is exposed to Python. I think the only way forstubgen-pyxto tell the difference would be to actually resolve thecimportand see what it is.I think it is better for users to use
importfor importing an extension type, which has (as far as I can tell) no behavioral difference, but makes it clear that the object is being imported for Python exposure.There is more information in this part of the docs particularly: