Skip to content

Commit 8579bef

Browse files
committed
use ruff.flake8-tidy-imports to enforce absolute imports
1 parent e22b475 commit 8579bef

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ extend-exclude = [
242242
"doc",
243243
"_typed_ops.pyi",
244244
]
245+
extend-safe-fixes = [
246+
"TID252", # absolute imports
247+
]
245248
target-version = "py39"
246249

247250
[tool.ruff.lint]
@@ -257,13 +260,18 @@ select = [
257260
"F", # Pyflakes
258261
"E", # Pycodestyle
259262
"W",
263+
"TID", # flake8-tidy-imports (absolute imports)
260264
"I", # isort
261265
"UP", # Pyupgrade
262266
]
263267

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

271+
[tool.ruff.lint.flake8-tidy-imports]
272+
# Disallow all relative imports.
273+
ban-relative-imports = "all"
274+
267275
[tool.pytest.ini_options]
268276
addopts = ["--strict-config", "--strict-markers"]
269277
filterwarnings = [

0 commit comments

Comments
 (0)