feat: support python 3.14 where return in finally is a syntax error#2416
Conversation
There was a problem hiding this comment.
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
pymatgenandjarvis-toolsoptional dependency constraints by Python version to support Python >= 3.13/3.14. - Refactor
optimade.validator.utils.test_casewrapper logic to remove the redundantfinally:block while preserving behavior (success/failure reporting, fail-fast behavior, and fatalSystemExithandling).
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.
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.