Skip to content

fix(linalg): Fix numpy annotations on Python<3.14 - #780

Merged
ValerianRey merged 3 commits into
mainfrom
fix-np-annotation
Sep 23, 2026
Merged

ValerianRey merged 3 commits into
mainfrom
fix-np-annotation

Conversation

@ValerianRey

Copy link
Copy Markdown
Member
  • Fix np.ndarray annotations when numpy is missing on python<3.14
  • Add test config for python<3.14 and none options
  • Add changelog entry

Basically, before Python 3.14, type annotations are executed eagerly unless we import annotations from __future__. So when numpy is not installed (when torchjd was installed without any optional deps), these type annotations lead to a NameError, making it impossible to even import torchjd.

I fixed the bug by adding this from __future__ import annotations, and I added a new tests config to make sure we don't run into this bug again.

@PierreQuinton IMO we could make a patch with this bug fix. It was quite an important problem.

@ValerianRey
ValerianRey requested review from a team and PierreQuinton as code owners September 23, 2026 14:02
@ValerianRey ValerianRey added cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: linalg labels Sep 23, 2026
@github-actions github-actions Bot changed the title Fix numpy annotations on Python<3.14 fix(linalg): Fix numpy annotations on Python<3.14 Sep 23, 2026
@ValerianRey
ValerianRey merged commit 24b23a2 into main Sep 23, 2026
18 of 20 checks passed
@ValerianRey
ValerianRey deleted the fix-np-annotation branch September 23, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: linalg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: import torchjd fails without numpy on Python < 3.14

2 participants