From 62f46fc55c434862c1418d0f86e378a1d6adf344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=90=E7=B2=92=20Yanli?= Date: Thu, 29 Jan 2026 16:45:07 +0800 Subject: [PATCH] chore(ty): Bootstrap ty type checking for api (#31681) --- .github/workflows/style.yml | 8 ++------ Makefile | 10 ++++++---- api/ty.toml | 24 +++++++++++++++++++++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index fdc05d1d65..cbd6edf94b 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -47,13 +47,9 @@ jobs: if: steps.changed-files.outputs.any_changed == 'true' run: uv run --directory api --dev lint-imports - - name: Run Basedpyright Checks + - name: Run Type Checks if: steps.changed-files.outputs.any_changed == 'true' - run: dev/basedpyright-check - - - name: Run Mypy Type Checks - if: steps.changed-files.outputs.any_changed == 'true' - run: uv --directory api run mypy --exclude-gitignore --exclude 'tests/' --exclude 'migrations/' --check-untyped-defs --disable-error-code=import-untyped . + run: make type-check - name: Dotenv check if: steps.changed-files.outputs.any_changed == 'true' diff --git a/Makefile b/Makefile index e92a7b1314..20cede9a5e 100644 --- a/Makefile +++ b/Makefile @@ -68,9 +68,11 @@ lint: @echo "โœ… Linting complete" type-check: - @echo "๐Ÿ“ Running type check with basedpyright..." - @uv run --directory api --dev basedpyright - @echo "โœ… Type check complete" + @echo "๐Ÿ“ Running type checks (basedpyright + mypy + ty)..." + @./dev/basedpyright-check $(PATH_TO_CHECK) + @uv --directory api run mypy --exclude-gitignore --exclude 'tests/' --exclude 'migrations/' --check-untyped-defs --disable-error-code=import-untyped . + @cd api && uv run ty check + @echo "โœ… Type checks complete" test: @echo "๐Ÿงช Running backend unit tests..." @@ -130,7 +132,7 @@ help: @echo " make format - Format code with ruff" @echo " make check - Check code with ruff" @echo " make lint - Format, fix, and lint code (ruff, imports, dotenv)" - @echo " make type-check - Run type checking with basedpyright" + @echo " make type-check - Run type checks (basedpyright, mypy, ty)" @echo " make test - Run backend unit tests (or TARGET_TESTS=./api/tests/)" @echo "" @echo "Docker Build Targets:" diff --git a/api/ty.toml b/api/ty.toml index bb4ff5bbcf..640ed6cdee 100644 --- a/api/ty.toml +++ b/api/ty.toml @@ -1,11 +1,33 @@ [src] exclude = [ - # TODO: enable when violations fixed + # deps groups (A1/A2/B/C/D/E) + # A1: foundational runtime typing / provider plumbing + "core/mcp/session", + "core/model_runtime/model_providers", + "core/workflow/nodes/protocols.py", + "libs/gmpy2_pkcs10aep_cipher.py", + # A2: workflow engine/nodes + "core/workflow", + "core/app/workflow", + "core/helper/code_executor", + # B: app runner + prompt + "core/prompt", + "core/app/apps/base_app_runner.py", "core/app/apps/workflow_app_runner.py", + # C: services/controllers/fields/libs + "services", "controllers/console/app", "controllers/console/explore", "controllers/console/datasets", "controllers/console/workspace", + "controllers/service_api/wraps.py", + "fields/conversation_fields.py", + "libs/external_api.py", + # D: observability + integrations + "core/ops", + "extensions", + # E: vector DB integrations + "core/rag/datasource/vdb", # non-producition or generated code "migrations", "tests",