Enforce the import conventions with ruff
flake8 has no plugin with configurable aliases
This commit is contained in:
parent
5ca16ae47c
commit
d006752194
1 changed files with 22 additions and 3 deletions
|
|
@ -333,10 +333,9 @@ multi_line_output = 3
|
|||
use_parentheses = true
|
||||
|
||||
# Comply with Google's Python Style Guide
|
||||
# => All imports go on a single line except the ones from the typing module
|
||||
# => All imports go on a single line
|
||||
# Source: https://google.github.io/styleguide/pyguide.html#313-imports-formatting
|
||||
force_single_line = true
|
||||
single_line_exclusions = ["typing"]
|
||||
|
||||
|
||||
|
||||
|
|
@ -482,6 +481,8 @@ select = [
|
|||
# =======================================
|
||||
# eradicate => no commented-out code
|
||||
"ERA",
|
||||
# flake8-import-conventions => Unified import aliases
|
||||
"ICN",
|
||||
# isort => imports are sorted
|
||||
"I",
|
||||
# Pylint's refactoring rules => simpler and smaller functions
|
||||
|
|
@ -531,13 +532,31 @@ parametrize-values-row-type = "tuple"
|
|||
parametrize-values-type = "list"
|
||||
|
||||
|
||||
[tool.ruff.lint.flake8-import-conventions]
|
||||
|
||||
# Import modules instead of objects from these modules
|
||||
banned-from = [
|
||||
"collections.abc",
|
||||
"nox.sessions",
|
||||
"typing",
|
||||
]
|
||||
|
||||
|
||||
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
|
||||
|
||||
"collections.abc" = "cabc"
|
||||
"sqlalchemy" = "sa"
|
||||
"sqlalchemy.dialects.postgresql" = "psql"
|
||||
"sqlalchemy.ext.hybrid" = "sa_hybrid"
|
||||
"typing" = "t"
|
||||
|
||||
|
||||
[tool.ruff.lint.isort] # aligned with [tool.isort] above
|
||||
|
||||
case-sensitive = false # Same as `isort`
|
||||
force-single-line = true
|
||||
lines-after-imports = 2
|
||||
order-by-type = false
|
||||
single-line-exclusions = ["typing"]
|
||||
|
||||
|
||||
[tool.ruff.lint.mccabe]
|
||||
|
|
|
|||
Loading…
Reference in a new issue