diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml new file mode 100644 index 0000000..b51b929 --- /dev/null +++ b/.github/workflows/typecheck.yml @@ -0,0 +1,32 @@ +name: Type Check (mypy) + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened] + paths: + - "kubeflow-pipelines/**/*.py" + - "pyproject.toml" + - "requirements-dev.txt" + - ".github/workflows/typecheck.yml" + +jobs: + typecheck: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + + - name: Install type checking dependencies + run: | + pip install mypy + pip install types-requests + + - name: Run mypy on kubeflow-pipelines + run: mypy kubeflow-pipelines/ diff --git a/pyproject.toml b/pyproject.toml index 919c1f2..b2cd48e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,4 +29,45 @@ lint.ignore = ["E203","E501","UP006","UP007","UP035"] [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py"] -addopts = ["--tb=short", "-v"] \ No newline at end of file +addopts = ["--tb=short", "-v"] + +[tool.mypy] +python_version = "3.12" +warn_return_any = true +warn_unused_configs = true +warn_unused_ignores = true +warn_redundant_casts = true +check_untyped_defs = true +disallow_untyped_defs = false +disallow_incomplete_defs = true +no_implicit_optional = true +strict_equality = true +show_error_codes = true +show_column_numbers = true + +# Exclude generated and non-source files +exclude = [ + "venv/", + "\\.venv/", + "\\.ipynb_checkpoints/", + "local_outputs/", +] + +# KFP components: imports happen inside function bodies and reference +# packages only available in the container base image (docling, etc.). +[[tool.mypy.overrides]] +module = [ + "kubeflow-pipelines.common.components", + "kubeflow-pipelines.docling-standard.standard_components", + "kubeflow-pipelines.docling-vlm.vlm_components", +] +disable_error_code = ["import-not-found"] + +# Third-party libraries without type stubs +[[tool.mypy.overrides]] +module = [ + "kfp.*", + "docling.*", + "docling_core.*", +] +ignore_missing_imports = true \ No newline at end of file