Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

ops: Add mypy and pyright to the code quality workflow

Karim shoairb1ce0b414b16
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