Make imports of external Python modules private#1948
Merged
speth merged 4 commits intoCantera:mainfrom Aug 22, 2025
Merged
Conversation
bryanwweber
reviewed
Aug 20, 2025
Member
bryanwweber
left a comment
There was a problem hiding this comment.
Thanks @speth I think this makes a lot of sense. It seems that pyright also respects libraries that have py.typed, so if our *.pyi files do not export numpy publicly then it may resolve the problem. See: microsoft/pylance-release#4518
| # This file is part of Cantera. See License.txt in the top-level directory or | ||
| # at https://cantera.org/license.txt for license and copyright information. | ||
| from __future__ import annotations | ||
| from __future__ import annotations as _annotations |
Member
There was a problem hiding this comment.
If we're only supporting 3.10+, do we need this anymore?
Contributor
There was a problem hiding this comment.
I had been wondering the same thing, but I believe it also enables some features which are not in 3.10. Though the only one I could definitively turn up was forward references, which I do utilize in several places.
(with the exception of __init__.py) Co-authored-by: Ingmar Schoegl <[email protected]>
ischoegl
approved these changes
Aug 22, 2025
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.
Changes proposed in this pull request
_sys) so they don't get included as members of thecanteramodule.np, which is used so extensively that I didn't want to have to change it. This one is removed by adelin__init__.py.This is an alternative approach to the same goal as #1947. There are a couple of things I discovered while preparing this.
warnings,Path,np, andosare members of thecanteranamespace, despite being deleted in__init__.pydirfunction, Jupyter's autocomplete (after import) and the autocomplete offrom cantera import ...in IPython are correctly limited.Checklist
scons build&scons test) and unit tests address code coverage