Skip to content

Conversation

@ischoegl
Copy link
Member

@ischoegl ischoegl commented Nov 24, 2025

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 PascalCase class names; at the same time, this would expand the scope significantly.

AI Statement (required)

  • Extensive use of generative AI. Significant portions of code or documentation were generated with AI, including logic and implementation decisions. All generated code and documentation were reviewed and understood by the contributor.

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • AI Statement is included
  • The pull request is ready for review

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 88.99371% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.80%. Comparing base (ecced37) to head (9b22835).

Files with missing lines Patch % Lines
interfaces/cython/cantera/cti2yaml.py 88.99% 24 Missing and 11 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@bryanwweber bryanwweber left a 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
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

@ischoegl ischoegl Jan 3, 2026

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.

@TimothyEDawson
Copy link
Contributor

TimothyEDawson commented Nov 25, 2025

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]
Copy link
Contributor

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.

Copy link
Member Author

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

@ischoegl
Copy link
Member Author

ischoegl commented Nov 27, 2025

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 mypy etc. to run locally. Will wait for the docs.

@TimothyEDawson
Copy link
Contributor

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 mypy etc. to run locally. Will wait for the docs.

What do you mean by "cannot get mypy etc. to run locally", exactly?

@ischoegl
Copy link
Member Author

What do you mean by "cannot get mypy etc. to run locally", exactly?

@TimothyEDawson ... I responded here: Cantera/enhancements#251 (comment)

@ischoegl
Copy link
Member Author

ischoegl commented Nov 30, 2025

Note that this command should report no errors:

mypy --config-file interfaces/cython/pyproject.toml interfaces/cython/cantera

For my setup, I get 172 errors on current main / git hash dff9016

@ischoegl ischoegl force-pushed the remove-cti2yaml.pyi branch 2 times, most recently from 7f56559 to e25d3ec Compare January 3, 2026 18:25
@ischoegl ischoegl force-pushed the remove-cti2yaml.pyi branch from e25d3ec to d533d40 Compare January 3, 2026 18:29
@ischoegl ischoegl marked this pull request as ready for review January 3, 2026 19:11
@ischoegl
Copy link
Member Author

ischoegl commented Jan 3, 2026

@bryanwweber / @TimothyEDawson ... I believe this is now ready for another round. The pyright errors related to pint threw me off, but they are non-blocking and exist on main as well.

@TimothyEDawson
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants