test: Silence SyntaxWarning when importing highspy#531
Merged
ValerianRey merged 1 commit intomainfrom Jan 28, 2026
Merged
Conversation
SyntaxWarning when importing highspy
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
6b3e484 to
42c4c63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today, highspy became a core dependency of cvxpy, which is one of our optional dependencies (installed when specifying
[nashmtl],[cagrad]or[full]optional dependencies when installing torchjd). Most of the CI tests are done with[full]install, so they includecvxpy, and thus they includehighspy. Coincidentally, it's actuallyqpsolversthat importshighspy, becausehighspywas also already an optional dependency ofqpsolvers. Now that it's installed (because ofcvxpy),qpsolversimports it.The problem is that there's a line of code in
highspythat triggers aSyntaxWarningon python 3.14 (because of this new PEP) when compiling the python file to bytecode (when first importing it). This warning is then transformed into an error by our pytest flag-W error. So the CI failed on python 3.14 except in the run usingnoneoptional dependencies.Users should barely notice anything:
highs.pyis compiled to bytecode. When using pip, it happens when installinghighspy. When usinguv, it happens when importing it for the very first time. The warning should thus appear only once, even if they restart python. In a CI environment where everything is reinstalled, it could appear every time though.This PR silences the warning in our tests so that CI doesn't break (without this, tests will fail at the next scheduled testing tomorrow). I think it's the only way to fix this. I tried adding an option to
pyproject.tomltellingpytestto filter out those warnings, but since the warning is raised as early as theconftest.py(which imports fromtorchjd, and thus fromqpsolversandhighspy), it didn't work.Note that when ERGO-Code/HiGHS#2777 gets fixed, we'll be able to remove this warning filterning.
@PierreQuinton FYI