Skip to content

Conversation

@khaeru
Copy link
Member

@khaeru khaeru commented Oct 24, 2025

Python 3.14 was released 2024-10-07. This PR is to:

  • Check/confirm that message-ix-models is compatible with the new version by updating CI workflows.
    • Update the GitHub ruleset config to require 3.14 jobs to pass, instead of 3.13.
  • Check/confirm the existence of compatible releases of upstream dependencies. If those releases are not immediately available, the PR can aid to monitor and track upstream issues.
  • Drop support for Python 3.9, which reached end-of-life (no more updates, even security updates) on 2025-10-07.
    • Remove any code marked as for Python 3.9 compatibility only. Depending on these changes, part or all of the functionality may remain usable with Python 3.9 if users have extreme need.
    • Make any general clean-ups or improvements possible with features available from Python 3.10.
      • Use the type union operator instead of typing.Optional and typing.Union. This is achieved by running ruff check --select F401,UP007,UP045 --fix or similar multiple times, plus some small manual clean-ups. See the ruff docs.
      • Use match/case instead of some if statements with multiple elif blocks. Too many instances in the code base to do in this PR, so not included.

How to review

For @glatterf42:

  • Read the commit messges
  • Note that the CI checks all pass.

Others notified as code owners:

  • No review needed.
  • Note the Python ≥3.10 semantics for type annotations, here, and use these in the future when updating these files.

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update doc/whatsnew.

After approval:

  • Rebase to drop the TEMPORARY commit(s).

@khaeru khaeru self-assigned this Oct 24, 2025
@khaeru khaeru added the enh New features or functionality label Oct 24, 2025
khaeru added a commit that referenced this pull request Oct 24, 2025
khaeru added a commit that referenced this pull request Oct 27, 2025
Unique hash for this configuration changed on the branch.
khaeru added a commit that referenced this pull request Oct 27, 2025
@khaeru khaeru force-pushed the python-3.14 branch 2 times, most recently from 1b0ba5b to c631b91 Compare October 27, 2025 10:41
khaeru added a commit that referenced this pull request Oct 27, 2025
Unique hash for this configuration changed on the branch.
khaeru added a commit that referenced this pull request Oct 27, 2025
khaeru added a commit that referenced this pull request Oct 27, 2025
- Use a test-local variable instead of caplog mechanism.
- Set core.cache_path directly, instead of relying on Context aliasing.
- Replace slice with a temporary, unhashable class.
khaeru added a commit that referenced this pull request Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 99.17355% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.7%. Comparing base (0cf55ca) to head (3f52423).

Files with missing lines Patch % Lines
message_ix_models/model/water/data/demands.py 66.6% 1 Missing ⚠️
message_ix_models/tools/wb.py 50.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #443     +/-   ##
=======================================
- Coverage   75.3%   74.7%   -0.7%     
=======================================
  Files        270     270             
  Lines      22331   22312     -19     
=======================================
- Hits       16836   16676    -160     
- Misses      5495    5636    +141     
Files with missing lines Coverage Δ
message_ix_models/model/build.py 100.0% <ø> (ø)
message_ix_models/model/buildings/__init__.py 25.2% <100.0%> (ø)
message_ix_models/model/config.py 93.1% <100.0%> (ø)
message_ix_models/model/emissions.py 98.7% <100.0%> (ø)
message_ix_models/model/macro.py 100.0% <100.0%> (ø)
message_ix_models/model/material/build.py 69.2% <100.0%> (+2.5%) ⬆️
message_ix_models/model/material/data_ammonia.py 94.2% <100.0%> (ø)
...ge_ix_models/model/material/data_other_industry.py 69.1% <100.0%> (ø)
message_ix_models/model/material/data_petro.py 80.2% <100.0%> (ø)
message_ix_models/model/material/data_util.py 75.9% <100.0%> (ø)
... and 80 more

... and 6 files with indirect coverage changes

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

@khaeru khaeru marked this pull request as ready for review October 27, 2025 13:27
khaeru added a commit that referenced this pull request Oct 27, 2025
Copy link
Member

@glatterf42 glatterf42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the commit messages and the passing tests, this looks good to me :)

- Update version classifiers.
- Bump requires-python to 3.10.
- Use Python 3.14:
  - with new(er) pstream versions, including main.
  - for single-version jobs.
- Use Python 3.10 for oldest upstream version.
Unique hash for this configuration changed on the branch.
- Use @DataClass(kw_only=True) where indicated.
- Use a test-local variable instead of caplog mechanism.
- Set core.cache_path directly, instead of relying on Context aliasing.
- Replace slice with a temporary, unhashable class.
@khaeru khaeru merged commit 7529cf9 into main Oct 27, 2025
7 of 8 checks passed
@khaeru khaeru deleted the python-3.14 branch October 27, 2025 16:01
@khaeru khaeru added this to the 2025-11 milestone Oct 29, 2025
junukitashepard pushed a commit that referenced this pull request Oct 30, 2025
Unique hash for this configuration changed on the branch.
junukitashepard pushed a commit that referenced this pull request Oct 30, 2025
- Use a test-local variable instead of caplog mechanism.
- Set core.cache_path directly, instead of relying on Context aliasing.
- Replace slice with a temporary, unhashable class.
junukitashepard pushed a commit that referenced this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enh New features or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants