Skip to content

test: Silence SyntaxWarning when importing highspy#531

Merged
ValerianRey merged 1 commit intomainfrom
fix-highspy-ci-issue
Jan 28, 2026
Merged

test: Silence SyntaxWarning when importing highspy#531
ValerianRey merged 1 commit intomainfrom
fix-highspy-ci-issue

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented Jan 28, 2026

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 include cvxpy, and thus they include highspy. Coincidentally, it's actually qpsolvers that imports highspy, because highspy was also already an optional dependency of qpsolvers. Now that it's installed (because of cvxpy), qpsolvers imports it.

The problem is that there's a line of code in highspy that triggers a SyntaxWarning on 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 using none optional dependencies.

Users should barely notice anything:

  • If they don't use python 3.14 they won't ever see the warning.
  • The warning is only triggered the first time highs.py is compiled to bytecode. When using pip, it happens when installing highspy. When using uv, 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.
  • It's only a warning for them unless they also treat warnings as errors.

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.toml telling pytest to filter out those warnings, but since the warning is raised as early as the conftest.py (which imports from torchjd, and thus from qpsolvers and highspy), it didn't work.

Note that when ERGO-Code/HiGHS#2777 gets fixed, we'll be able to remove this warning filterning.

@PierreQuinton FYI

@ValerianRey ValerianRey added the cc: test Conventional commit type for changes to tests. label Jan 28, 2026
@ValerianRey ValerianRey self-assigned this Jan 28, 2026
@ValerianRey ValerianRey added the cc: test Conventional commit type for changes to tests. label Jan 28, 2026
@ValerianRey ValerianRey changed the title test: Silence SyntaxWarning when importing highspy test: Silence SyntaxWarning when importing highspy Jan 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

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

@ValerianRey ValerianRey merged commit 0640ed5 into main Jan 28, 2026
14 checks passed
@ValerianRey ValerianRey deleted the fix-highspy-ci-issue branch January 28, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: test Conventional commit type for changes to tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant