-
-
Notifications
You must be signed in to change notification settings - Fork 397
Consolidate type hinting in cti2yaml #2057
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
base: main
Are you sure you want to change the base?
Conversation
fd0e76e to
21c7a44
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2057 +/- ##
==========================================
+ Coverage 76.75% 76.80% +0.04%
==========================================
Files 457 457
Lines 53699 53855 +156
Branches 9121 9127 +6
==========================================
+ Hits 41219 41362 +143
- Misses 9375 9382 +7
- Partials 3105 3111 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bryanwweber
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.
I know this is still in draft but I wanted to leave a couple comments while you're working on it
| # constants that can be used in .cti files | ||
| OneAtm = 1.01325e5 | ||
| OneBar = 1.0e5 | ||
| OneAtm: float = 1.01325e5 |
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.
Types for literals like this will be inferred by the type checker, so you can remove this
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.
Agreed, but the mypy settings are quite aggressive so this errors if left off.
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.
Then I think we should mark them as Final[float] etc. so that we're actually adding information here.
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.
Removed the type as it appears to work after all.
Nevermind: worked on my machine, but not on CI. The --verifytypes option makes the Final[float] etc. necessary.
|
I would have gladly consolidated the remaining type stubs for the various conversion scripts, but was told that they're not a high priority. As you can see, it can get pretty annoying! I'll leave a few comments based on the errors I'm seeing right now. Note that this command should report no errors: mypy --config-file interfaces/cython/pyproject.toml interfaces/cython/cantera |
| try: | ||
| from cantera import Solution, Interface | ||
| # Note: import-not-found needed in standalone mode, attr-defined needed in package mode | ||
| from cantera import Solution, Interface # type: ignore[import-not-found,attr-defined] |
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.
This is flagged as an error: unused-ignore within the mypy check, but I can see how it might be required for the stubtest checks. I'm not sure what to do about that, exactly, but we might need to change unused-ignore to a warning instead of an error. That should be an option that can be set in the pyproject.toml file.
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.
Added disable_error_code = ["unused-ignore"] to pyproject.toml
|
I’m going to leave this PR here (in draft mode). Full disclosure: I was testing automated coding for this merge of stub files and Python files. I’m pleased with the outcome, but don’t want to work on this while I cannot get |
What do you mean by "cannot get |
@TimothyEDawson ... I responded here: Cantera/enhancements#251 (comment) |
For my setup, I get 172 errors on current |
7f56559 to
e25d3ec
Compare
e25d3ec to
d533d40
Compare
|
@bryanwweber / @TimothyEDawson ... I believe this is now ready for another round. The |
|
Awesome, I'll check it out soon! On a related note, I also have finished a first draft of the dev documentation which I'll be pushing soon. |
Changes proposed in this pull request
This PR introduces a consolidation of type hinting - having stub files separate from pure Python files is not ideal. The consolidation triggers more thorough type checking.
Aside: this could be further updated by forcing
PascalCaseclass names; at the same time, this would expand the scope significantly.AI Statement (required)
Checklist
scons build&scons test) and unit tests address code coverage