yiliu30 / py-style-test

0 stars 1 forks source link

use google style's `import` statements #1

Open yiliu30 opened 1 month ago

yiliu30 commented 1 month ago

https://google.github.io/styleguide/pyguide.html#22-imports

yiliu30 commented 1 month ago

Check the import statements

https://docs.astral.sh/ruff/rules/banned-import-from/

[lint.flake8-import-conventions]
# Declare the banned `from` imports.
banned-from = ["os.path", "numpy", "pandas", "numbers.util"]
# "numpy", "pandas" are defaults
# https://github.com/joaopalmeiro/flake8-import-conventions?tab=readme-ov-file#flake8-codes
ruffimport:
    ruff check --select ICN

rufffiximport:
    ruff check --select ICN --unsafe-fixes --fix
yiliu30 commented 1 month ago

Rule to enforce import module only #3045 https://github.com/astral-sh/ruff/issues/3045 Implement flake8-import-restrictions #5841 https://github.com/astral-sh/ruff/issues/5841

https://github.com/atollk/flake8-import-restrictions#imr241