From 559abfbaa08602db31052313e034bfc3293bae15 Mon Sep 17 00:00:00 2001 From: phv2312 Date: Sat, 28 Feb 2026 16:21:24 +0700 Subject: [PATCH] refactor: strict pre-commit rules --- .pre-commit-config.yaml | 60 +++++++++++------------------------------ pyproject.toml | 23 ++++++++++++++-- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11a82ee1..a9ea1227 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-yaml args: ["--unsafe"] @@ -14,56 +14,28 @@ repos: - id: check-added-large-files args: ["--maxkb=750"] - id: debug-statements - - repo: https://github.com/ambv/black - rev: 22.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.0 hooks: - - id: black - 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 + - id: ruff-check args: - [ - "--in-place", - "--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] + - --fix + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.7.1" + rev: "v1.19.1" hooks: - id: mypy + files: "^(libs/)" additional_dependencies: - [ - types-PyYAML==6.0.12.11, - "types-requests", - "sqlmodel", - "types-Markdown", - "types-cachetools", - types-tzlocal, - ] - args: ["--check-untyped-defs", "--ignore-missing-imports"] - exclude: "^templates/" + - pydantic + - types-PyYAML==6.0.12.11, + - "types-requests" + - "sqlmodel" + - "types-Markdown" + - "types-cachetools" + - types-tzlocal - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: diff --git a/pyproject.toml b/pyproject.toml index f089d23a..4cab5cb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,5 +64,24 @@ ignore-words-list = "llm,fo" quiet-level = 3 check-filenames = "" -[tool.isort] -known_first_party = ["kotaemon"] +[tool.ruff] +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