From b1ce0b414b167d7d5b08c9016cc954868ebe2818 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Sat, 7 Feb 2026 17:28:44 +0200 Subject: [PATCH] ops: Add mypy and pyright to the code quality workflow --- .github/workflows/code-quality.yml | 36 +++++++++++++++++++++++++++++- pyproject.toml | 14 +++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 6e15d6a..4afdfb4 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -51,7 +51,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install bandit[toml] ruff vermin + pip install bandit[toml] ruff vermin mypy pyright + pip install -e ".[all]" + pip install lxml-stubs - name: Run Bandit (Security Linter) id: bandit @@ -86,6 +88,22 @@ jobs: vermin -t=3.10- --violations --eval-annotations --no-tips scrapling/ echo "::endgroup::" + - name: Run Mypy (Static Type Checker) + id: mypy + continue-on-error: true + run: | + echo "::group::Mypy - Static Type Checker" + mypy scrapling/ + echo "::endgroup::" + + - name: Run Pyright (Static Type Checker) + id: pyright + continue-on-error: true + run: | + echo "::group::Pyright - Static Type Checker" + pyright scrapling/ + echo "::endgroup::" + - name: Check results and create summary if: always() run: | @@ -127,6 +145,22 @@ jobs: all_passed=false fi + # Check Mypy + if [ "${{ steps.mypy.outcome }}" == "success" ]; then + echo "✅ **Mypy (Type Checker)**: Passed" >> $GITHUB_STEP_SUMMARY + else + echo "❌ **Mypy (Type Checker)**: Failed" >> $GITHUB_STEP_SUMMARY + all_passed=false + fi + + # Check Pyright + if [ "${{ steps.pyright.outcome }}" == "success" ]; then + echo "✅ **Pyright (Type Checker)**: Passed" >> $GITHUB_STEP_SUMMARY + else + echo "❌ **Pyright (Type Checker)**: Failed" >> $GITHUB_STEP_SUMMARY + all_passed=false + fi + echo "" >> $GITHUB_STEP_SUMMARY if [ "$all_passed" == "true" ]; then diff --git a/pyproject.toml b/pyproject.toml index 328725e..3d884e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,4 +105,16 @@ include-package-data = true [tool.setuptools.packages.find] where = ["."] -include = ["scrapling*"] \ No newline at end of file +include = ["scrapling*"] + +[tool.mypy] +python_version = "3.10" +warn_unused_configs = true +ignore_missing_imports = true +check_untyped_defs = true + +[tool.pyright] +pythonVersion = "3.10" +typeCheckingMode = "basic" +include = ["scrapling"] +ignore = ["tests", "benchmarks.py"] \ No newline at end of file