Karim shoair commited on
Commit
847727e
·
1 Parent(s): c2dbf4c

ops: Add mypy and pyright to the code quality workflow

Browse files
.github/workflows/code-quality.yml CHANGED
@@ -51,7 +51,9 @@ jobs:
51
  - name: Install dependencies
52
  run: |
53
  python -m pip install --upgrade pip
54
- pip install bandit[toml] ruff vermin
 
 
55
 
56
  - name: Run Bandit (Security Linter)
57
  id: bandit
@@ -86,6 +88,22 @@ jobs:
86
  vermin -t=3.10- --violations --eval-annotations --no-tips scrapling/
87
  echo "::endgroup::"
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  - name: Check results and create summary
90
  if: always()
91
  run: |
@@ -127,6 +145,22 @@ jobs:
127
  all_passed=false
128
  fi
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  echo "" >> $GITHUB_STEP_SUMMARY
131
 
132
  if [ "$all_passed" == "true" ]; then
 
51
  - name: Install dependencies
52
  run: |
53
  python -m pip install --upgrade pip
54
+ pip install bandit[toml] ruff vermin mypy pyright
55
+ pip install -e ".[all]"
56
+ pip install lxml-stubs
57
 
58
  - name: Run Bandit (Security Linter)
59
  id: bandit
 
88
  vermin -t=3.10- --violations --eval-annotations --no-tips scrapling/
89
  echo "::endgroup::"
90
 
91
+ - name: Run Mypy (Static Type Checker)
92
+ id: mypy
93
+ continue-on-error: true
94
+ run: |
95
+ echo "::group::Mypy - Static Type Checker"
96
+ mypy scrapling/
97
+ echo "::endgroup::"
98
+
99
+ - name: Run Pyright (Static Type Checker)
100
+ id: pyright
101
+ continue-on-error: true
102
+ run: |
103
+ echo "::group::Pyright - Static Type Checker"
104
+ pyright scrapling/
105
+ echo "::endgroup::"
106
+
107
  - name: Check results and create summary
108
  if: always()
109
  run: |
 
145
  all_passed=false
146
  fi
147
 
148
+ # Check Mypy
149
+ if [ "${{ steps.mypy.outcome }}" == "success" ]; then
150
+ echo "✅ **Mypy (Type Checker)**: Passed" >> $GITHUB_STEP_SUMMARY
151
+ else
152
+ echo "❌ **Mypy (Type Checker)**: Failed" >> $GITHUB_STEP_SUMMARY
153
+ all_passed=false
154
+ fi
155
+
156
+ # Check Pyright
157
+ if [ "${{ steps.pyright.outcome }}" == "success" ]; then
158
+ echo "✅ **Pyright (Type Checker)**: Passed" >> $GITHUB_STEP_SUMMARY
159
+ else
160
+ echo "❌ **Pyright (Type Checker)**: Failed" >> $GITHUB_STEP_SUMMARY
161
+ all_passed=false
162
+ fi
163
+
164
  echo "" >> $GITHUB_STEP_SUMMARY
165
 
166
  if [ "$all_passed" == "true" ]; then
pyproject.toml CHANGED
@@ -105,4 +105,16 @@ include-package-data = true
105
 
106
  [tool.setuptools.packages.find]
107
  where = ["."]
108
- include = ["scrapling*"]
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  [tool.setuptools.packages.find]
107
  where = ["."]
108
+ include = ["scrapling*"]
109
+
110
+ [tool.mypy]
111
+ python_version = "3.10"
112
+ warn_unused_configs = true
113
+ ignore_missing_imports = true
114
+ check_untyped_defs = true
115
+
116
+ [tool.pyright]
117
+ pythonVersion = "3.10"
118
+ typeCheckingMode = "basic"
119
+ include = ["scrapling"]
120
+ ignore = ["tests", "benchmarks.py"]