Skip to content

fix: Add __all__ in __init__.py files#501

Merged
ValerianRey merged 3 commits intomainfrom
add_all
Dec 27, 2025
Merged

fix: Add __all__ in __init__.py files#501
ValerianRey merged 3 commits intomainfrom
add_all

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

When using torchjd in VSCode with PyLance, I had warnings telling me that my imports were incorrect. I think this is because we didn't have the __all__ list of publicly exported things. Technically, __all__ is supposed to define what can be imported with wildcard imports (e.g. from torchjd import *), and it shouldn't be necessary for normal imports. I previously didn't want to add the __all__ list because it's easy to forget to add one element to such a list. However, if we remove the line '--per-file-ignores=*/__init__.py:F401', # Ignore module imported but unused problems in __init__.py files. from .pre-commit-config.yaml, the linter will warn us whenever we import something in __init__.py and it's not in the list. So I also removed that line as a safeguard.

I think working with PyLance is quite common so this is important IMO. I'll make a release with it if you agree @PierreQuinton.

@ValerianRey ValerianRey added the cc: fix Conventional commit type for bug fixes of the actual library (changes to src). label Dec 26, 2025
@ValerianRey ValerianRey self-assigned this Dec 26, 2025
@ValerianRey ValerianRey changed the title Add __all__ fix: Add __all__ in __init__.py files Dec 26, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/torchjd/aggregation/__init__.py 100.00% <100.00%> (ø)
src/torchjd/autogram/__init__.py 100.00% <100.00%> (ø)
src/torchjd/autojac/__init__.py 100.00% <100.00%> (ø)
src/torchjd/autojac/_transform/__init__.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PierreQuinton
Copy link
Copy Markdown
Contributor

LGTM, this deserves a release.

@ValerianRey ValerianRey merged commit cc0ce66 into main Dec 27, 2025
21 checks passed
@ValerianRey ValerianRey deleted the add_all branch December 27, 2025 13:36
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).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants