Skip to content

Commit 208969b

Browse files
authored
use ruff.flake8-tidy-imports to enforce absolute imports (#8680)
1 parent 81f38f3 commit 208969b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ repos:
1010
- id: check-yaml
1111
- id: debug-statements
1212
- id: mixed-line-ending
13-
- repo: https://github.com/MarcoGorelli/absolufy-imports
14-
rev: v0.3.1
15-
hooks:
16-
- id: absolufy-imports
17-
name: absolufy-imports
18-
files: ^xarray/
1913
- repo: https://github.com/astral-sh/ruff-pre-commit
2014
# Ruff version.
2115
rev: 'v0.1.9'

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,15 @@ extend-exclude = [
242242
"doc",
243243
"_typed_ops.pyi",
244244
]
245+
extend-safe-fixes = [
246+
"TID252", # absolute imports
247+
]
245248
target-version = "py39"
246249

250+
[tool.ruff.per-file-ignores]
251+
# don't enforce absolute imports
252+
"asv_bench/**" = ["TID252"]
253+
247254
[tool.ruff.lint]
248255
# E402: module level import not at top of file
249256
# E501: line too long - let black worry about that
@@ -257,13 +264,18 @@ select = [
257264
"F", # Pyflakes
258265
"E", # Pycodestyle
259266
"W",
267+
"TID", # flake8-tidy-imports (absolute imports)
260268
"I", # isort
261269
"UP", # Pyupgrade
262270
]
263271

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

275+
[tool.ruff.lint.flake8-tidy-imports]
276+
# Disallow all relative imports.
277+
ban-relative-imports = "all"
278+
267279
[tool.pytest.ini_options]
268280
addopts = ["--strict-config", "--strict-markers"]
269281
filterwarnings = [

0 commit comments

Comments
 (0)