The current __init__.py files in the repository only import symbols, but do not re-export them per Python standards.
All the imports, in all the __init__.py files are currently raising a F401 error when linted.
Steps to reproduce the behavior:
Run a linter on the code base. Using ruff with
python -m ruff check .
outputs
src/tqec/__init__.py:2:5: F401 `.circuit` imported but unused; consider adding to `__all__` or using a redundant alias
src/tqec/__init__.py:3:5: F401 `.noise_models` imported but unused; consider adding to `__all__` or using a redundant alias
# [a lot more lines]
src/tqec/templates/constructions/__init__.py:3:5: F401 `.qubit.QubitRectangleTemplate` imported but unused; consider adding to `__all__` or using a redundant alias
src/tqec/templates/constructions/__init__.py:4:5: F401 `.qubit.QubitSquareTemplate` imported but unused; consider adding to `__all__` or using a redundant alias
Found 99 errors.
Expected behavior
No linter error.
How to fix
The ruff linter has two options:
include the symbols that are meant to be re-exported in the __all__ special variable.
use the import X as X format to explicitly mark the symbol X as re-exported.
I spent some time to search for the rationale behind F401 and found this comment.
I will add a third option:
disable the F401 warning for this specific case.
As we already ruled out the __all__ approach in a previous PR, I guess we are left with 2 or 3.
Python dependency versions (please complete for backend bugs)
Run pip freeze and put the output in the <details> element below.
Describe the bug
The current
__init__.py
files in the repository only import symbols, but do not re-export them per Python standards.All the imports, in all the
__init__.py
files are currently raising aF401
error when linted.Steps to reproduce the behavior:
Run a linter on the code base. Using
ruff
withoutputs
Expected behavior
No linter error.
How to fix
The
ruff
linter has two options:__all__
special variable.import X as X
format to explicitly mark the symbolX
as re-exported.I spent some time to search for the rationale behind
F401
and found this comment.I will add a third option:
F401
warning for this specific case.As we already ruled out the
__all__
approach in a previous PR, I guess we are left with 2 or 3.Python dependency versions (please complete for backend bugs)
Run
pip freeze
and put the output in the<details>
element below.