Skip to content

feat: support python 3.14 where return in finally is a syntax error#2416

Merged
ml-evs merged 3 commits into
Materials-Consortia:mainfrom
Lattay:python_14
Jul 2, 2026
Merged

feat: support python 3.14 where return in finally is a syntax error#2416
ml-evs merged 3 commits into
Materials-Consortia:mainfrom
Lattay:python_14

Conversation

@Lattay

@Lattay Lattay commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I made sure the full test suite passes in a fresh python 3.14 environment.
This implied specifying a version for pymatgen and jarvis in pyproject.toml and removing a finally block that was redundant, because it was causing a SyntaxWarning that wass promoted to an exception by pytest.

Relevent links for the handling of control flow inside the finally:
https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions
https://peps.python.org/pep-0765/

Fortunately, the finally was redundant as no exception can reach it as per the catchall except just before.

@Lattay Lattay requested review from CasperWA and ml-evs as code owners July 1, 2026 13:35
@Lattay Lattay changed the title feat: support python 3.14 where return in finally is a syntax error [WIPfeat: support python 3.14 where return in finally is a syntax error Jul 1, 2026
@Lattay Lattay changed the title [WIPfeat: support python 3.14 where return in finally is a syntax error [WIP] feat: support python 3.14 where return in finally is a syntax error Jul 1, 2026
@Lattay Lattay changed the title [WIP] feat: support python 3.14 where return in finally is a syntax error feat: support python 3.14 where return in finally is a syntax error Jul 1, 2026
@ml-evs ml-evs requested a review from Copilot July 2, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the project to be compatible with Python 3.14 by adjusting optional dependency constraints for newer Python versions and refactoring validator control flow to avoid return/control-flow in a finally block that is no longer permitted.

Changes:

  • Split pymatgen and jarvis-tools optional dependency constraints by Python version to support Python >= 3.13/3.14.
  • Refactor optimade.validator.utils.test_case wrapper logic to remove the redundant finally: block while preserving behavior (success/failure reporting, fail-fast behavior, and fatal SystemExit handling).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
pyproject.toml Updates optional dependency version markers to support Python >= 3.13/3.14.
optimade/validator/utils.py Removes the finally block and restructures post-processing to avoid Python 3.14 control-flow-in-finally issues.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread optimade/validator/utils.py
Comment thread optimade/validator/utils.py
@ml-evs

ml-evs commented Jul 2, 2026

Copy link
Copy Markdown
Member

pre-commit.ci autofix

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.28%. Comparing base (d8b22c0) to head (b351b53).

Files with missing lines Patch % Lines
optimade/validator/utils.py 94.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2416      +/-   ##
==========================================
- Coverage   90.32%   90.28%   -0.04%     
==========================================
  Files          78       78              
  Lines        5086     5086              
==========================================
- Hits         4594     4592       -2     
- Misses        492      494       +2     
Flag Coverage Δ
project 90.28% <94.59%> (-0.04%) ⬇️
validator 90.28% <94.59%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@ml-evs ml-evs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@ml-evs ml-evs merged commit 01b4260 into Materials-Consortia:main Jul 2, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants