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 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.

Analogous to #881.

How to review

  • Read the diff,
  • Note that the CI checks all pass.

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update release notes.

After approval, before merge:

  • Rebase, dropping TEMPORARY commit(s).

@khaeru khaeru self-assigned this Oct 24, 2025
@khaeru khaeru added the enh New features & functionality label Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.5%. Comparing base (fa45877) to head (13c5b5b).
⚠️ Report is 9 commits behind head on main.

⚠️ Current head 13c5b5b differs from pull request most recent head 5bd58c3

Please upload reports for the commit 5bd58c3 to get more accurate results.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #985   +/-   ##
=====================================
  Coverage   96.4%   96.5%           
=====================================
  Files         60      60           
  Lines       5138    5155   +17     
=====================================
+ Hits        4957    4975   +18     
+ Misses       181     180    -1     
Files with missing lines Coverage Δ
message_ix/common.py 100.0% <100.0%> (ø)
message_ix/core.py 97.4% <100.0%> (ø)
message_ix/macro/calibrate.py 96.7% <100.0%> (ø)
message_ix/report/__init__.py 100.0% <100.0%> (ø)
message_ix/report/pyam.py 100.0% <100.0%> (ø)
message_ix/testing/__init__.py 100.0% <100.0%> (ø)
message_ix/tests/model/message/test_cap_comm.py 100.0% <100.0%> (ø)
message_ix/tests/model/test_message.py 100.0% <100.0%> (ø)
message_ix/tests/report/test_operator.py 100.0% <100.0%> (ø)
message_ix/tests/test_core.py 100.0% <100.0%> (ø)
... and 30 more

khaeru added a commit that referenced this pull request Oct 24, 2025
@khaeru khaeru requested a review from glatterf42 October 24, 2025 12:50
khaeru added a commit that referenced this pull request Oct 24, 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.

Thanks for these cleanups! I think the test failures are flaky, but I've triggered a rerun to be sure. Since all tests are passing here, I think this PR includes the fixes for our nightly CI failures, so it would be great to merge this today :)

@khaeru
Copy link
Member Author

khaeru commented Oct 27, 2025

FAILED message_ix/tests/report/test_operator.py::test_stacked_bar - _tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    {C:\hostedtoolcache\windows\Python\3.12.10\x64\tcl\tcl8.6}

C:/hostedtoolcache/windows/Python/3.12.10/x64/tcl/tcl8.6/init.tcl: couldn't read file "C:/hostedtoolcache/windows/Python/3.12.10/x64/tcl/tcl8.6/init.tcl": No error
couldn't read file "C:/hostedtoolcache/windows/Python/3.12.10/x64/tcl/tcl8.6/init.tcl": No error
    while executing
"source C:/hostedtoolcache/windows/Python/3.12.10/x64/tcl/tcl8.6/init.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $tclfile]"


This probably means that Tcl wasn't installed properly.

I also ran into this in khaeru/genno#179; will cherry-pick and use the same workaround here.

khaeru added a commit that referenced this pull request Oct 27, 2025
@khaeru
Copy link
Member Author

khaeru commented Oct 27, 2025

With that change, the checks all pass (although slowly 🥲). I'll now rebase to drop the TEMPORARY commit, and then merge.

- Update version classifiers.
- Bump requires-python to 3.10.
- Add Python 3.14; use for single-version jobs.
- Drop Python 3.9. Drop use of macos-13 for Python 3.9.
- Drop import & use of typing.{Optional,Union}.
@khaeru khaeru merged commit f97e386 into main Oct 27, 2025
6 of 7 checks passed
@khaeru khaeru deleted the python-3.14 branch October 27, 2025 09:45
@khaeru khaeru added this to the 3.12 milestone Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enh New features & functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants