refactor: strict pre-commit rules

This commit is contained in:
phv2312
2026-02-28 16:21:24 +07:00
parent fe52d208e2
commit 559abfbaa0
2 changed files with 37 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0 rev: v5.0.0
hooks: hooks:
- id: check-yaml - id: check-yaml
args: ["--unsafe"] args: ["--unsafe"]
@@ -14,56 +14,28 @@ repos:
- id: check-added-large-files - id: check-added-large-files
args: ["--maxkb=750"] args: ["--maxkb=750"]
- id: debug-statements - id: debug-statements
- repo: https://github.com/ambv/black - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 22.3.0 rev: v0.15.0
hooks: hooks:
- id: black - id: ruff-check
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
language_version: python3.10
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ["--max-line-length", "88", "--extend-ignore", "E203"]
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: args:
[ - --fix
"--in-place", - id: ruff-format
"--remove-unused-variables",
"--remove-all-unused-imports",
"--ignore-init-module-imports",
"--exclude=tests/*",
]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
types_or: [markdown, yaml]
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.7.1" rev: "v1.19.1"
hooks: hooks:
- id: mypy - id: mypy
files: "^(libs/)"
additional_dependencies: additional_dependencies:
[ - pydantic
types-PyYAML==6.0.12.11, - types-PyYAML==6.0.12.11,
"types-requests", - "types-requests"
"sqlmodel", - "sqlmodel"
"types-Markdown", - "types-Markdown"
"types-cachetools", - "types-cachetools"
types-tzlocal, - types-tzlocal
]
args: ["--check-untyped-defs", "--ignore-missing-imports"]
exclude: "^templates/"
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.2.4 rev: v2.4.1
hooks: hooks:
- id: codespell - id: codespell
additional_dependencies: additional_dependencies:

View File

@@ -64,5 +64,24 @@ ignore-words-list = "llm,fo"
quiet-level = 3 quiet-level = 3
check-filenames = "" check-filenames = ""
[tool.isort] [tool.ruff]
known_first_party = ["kotaemon"] exclude = ["*.ipynb"]
[tool.mypy]
python_version = "3.12"
files = ["libs"]
check_untyped_defs = true
disallow_untyped_defs = true
disallow_untyped_calls = true
disallow_any_generics = true
ignore_missing_imports = true
follow_imports = "normal"
no_implicit_reexport = true
warn_redundant_casts = true
warn_unused_ignores = true
plugins = ["pydantic.mypy"]
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true