We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing file ruff-E402-addsitedir.py:
ruff-E402-addsitedir.py
#!/usr/bin/env python import os import site import sys import sysconfig site.addsitedir( os.path.join( os.path.dirname(os.path.dirname(__file__)), sysconfig.get_path("purelib", vars={"base": "."}), ) ) from mypkg.__main__ import main if __name__ == "__main__": sys.argv[0] = sys.argv[0].removesuffix(".py") sys.exit(main())
Ruff check complains:
$ ruff check --select E402 ruff-E402-addsitedir.py ruff-E402-addsitedir.py:15:1: E402 Module level import not at top of file | 13 | ) 14 | 15 | from mypkg.__main__ import main | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 16 | 17 | if __name__ == "__main__": | Found 1 error.
Looking at the code, sys.path and some others cases are handled
sys.path
https://github.com/astral-sh/ruff/blob/0.9.6/crates/ruff_linter/src/checkers/ast/mod.rs#L552-L562
ruff/crates/ruff_linter/src/checkers/ast/mod.rs
Lines 552 to 562 in 524cf6e
but site.addsitedir seems missing, although it appends to sys.path internally:
site.addsitedir
https://github.com/python/cpython/blob/3.13/Lib/site.py#L238
BTW, thanks for Ruff, it's a great piece of software!
The text was updated successfully, but these errors were encountered:
I can do the fix to handle this case if needed ;-)
Sorry, something went wrong.
site.addsitedir(...)
I think this can be closed ;-)
Indeed, Github did not notified me automatically of the Pull Request.
Thank you for fixing this so quickly!
VascoSch92
No branches or pull requests
Description
Failing file
ruff-E402-addsitedir.py
:Ruff check complains:
Looking at the code,
sys.path
and some others cases are handledhttps://github.com/astral-sh/ruff/blob/0.9.6/crates/ruff_linter/src/checkers/ast/mod.rs#L552-L562
ruff/crates/ruff_linter/src/checkers/ast/mod.rs
Lines 552 to 562 in 524cf6e
but
site.addsitedir
seems missing, although it appends tosys.path
internally:https://github.com/python/cpython/blob/3.13/Lib/site.py#L238
BTW, thanks for Ruff, it's a great piece of software!
The text was updated successfully, but these errors were encountered: