Skip to content

Commit

Permalink
use ruff.flake8-tidy-imports to enforce absolute imports (#8680)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathause authored Jan 30, 2024
1 parent 81f38f3 commit 208969b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ repos:
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports
files: ^xarray/
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.9'
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,15 @@ extend-exclude = [
"doc",
"_typed_ops.pyi",
]
extend-safe-fixes = [
"TID252", # absolute imports
]
target-version = "py39"

[tool.ruff.per-file-ignores]
# don't enforce absolute imports
"asv_bench/**" = ["TID252"]

[tool.ruff.lint]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
Expand All @@ -257,13 +264,18 @@ select = [
"F", # Pyflakes
"E", # Pycodestyle
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"UP", # Pyupgrade
]

[tool.ruff.lint.isort]
known-first-party = ["xarray"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"

[tool.pytest.ini_options]
addopts = ["--strict-config", "--strict-markers"]
filterwarnings = [
Expand Down

0 comments on commit 208969b

Please sign in to comment.