Replace isort, black with ruff for faster linting, formatting

This commit is contained in:
Debanjum
2025-07-16 13:51:14 -07:00
parent 8700fb8937
commit 4a3ed9e5a4
2 changed files with 31 additions and 14 deletions

View File

@@ -1,8 +1,12 @@
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 23.1.0 rev: v0.12.3
hooks: hooks:
- id: black - id: ruff-check
args: [ --fix ]
files: \.py$
- id: ruff-format
files: \.py$
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.4.0
@@ -16,13 +20,6 @@ repos:
- id: check-toml - id: check-toml
- id: check-yaml - id: check-yaml
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.0 rev: v1.0.0
hooks: hooks:

View File

@@ -122,7 +122,7 @@ dev = [
"freezegun >= 1.2.0", "freezegun >= 1.2.0",
"factory-boy >= 3.2.1", "factory-boy >= 3.2.1",
"mypy >= 1.0.1", "mypy >= 1.0.1",
"black >= 23.1.0", "ruff >= 0.12.0",
"pre-commit >= 3.0.4", "pre-commit >= 3.0.4",
"gitpython ~= 3.1.43", "gitpython ~= 3.1.43",
"datasets", "datasets",
@@ -149,11 +149,31 @@ non_interactive = true
show_error_codes = true show_error_codes = true
warn_unused_ignores = false warn_unused_ignores = false
[tool.black] [tool.ruff]
line-length = 120 line-length = 120
[tool.isort] [tool.ruff.lint]
profile = "black" select = ["E", "F", "I"] # Enable error, warning, and import checks
ignore = [
"E501", # Ignore line length
"F405", # Ignore name not defined (e.g., from imports)
"E402", # Ignore module level import not at top of file
]
unfixable = ["F841"] # Don't auto-remove unused variables
exclude = [ "tests/*.py" ]
[tool.ruff.lint.per-file-ignores]
"src/khoj/main.py" = [
"I001", # Ignore Import order
"I002", # Ignore Import not at top of file
"E402", # Ignore module level import not at top of file
]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.ruff.lint.isort]
known-first-party = ["khoj"]
[tool.pytest.ini_options] [tool.pytest.ini_options]
addopts = "--strict-markers" addopts = "--strict-markers"