Enable strict type checking with mypy #19532
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow that runs lint on the frontend and python code | |
name: Lint | |
# The jobs in this workflow are required, so they must run at all times | |
# Always run on "main" | |
# Always run on PRs | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique group | |
concurrency: | |
group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
# Run lint on the frontend code | |
lint-frontend: | |
name: Lint frontend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: | | |
cd frontend | |
npm install --frozen-lockfile | |
- name: Lint and TypeScript compilation | |
run: | | |
cd frontend | |
npm run lint | |
npm run make-i18n && tsc | |
# Run lint on the python code | |
lint-python: | |
name: Lint python | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: 'pip' | |
- name: Install pre-commit | |
run: pip install pre-commit==3.7.0 | |
- name: Install project in editable mode | |
run: pip install -e . | |
- name: Run pre-commit hooks | |
run: pre-commit run --files openhands/**/* evaluation/**/* tests/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml | |
- name: Run mypy directly (for better error reporting) | |
if: always() # Run even if pre-commit fails | |
run: | | |
pip install mypy==1.9.0 \ | |
types-requests types-setuptools types-pyyaml types-toml \ | |
types-redis types-protobuf types-python-dateutil types-pyjwt \ | |
types-docutils types-Pillow types-boto3 types-cryptography \ | |
types-Jinja2 types-MarkupSafe types-click types-filelock \ | |
types-decorator types-docopt types-emoji types-enum34 types-paramiko | |
PYTHONPATH=$PWD mypy --config-file dev_config/python/mypy.ini --scripts-are-modules openhands/ | |
# Check version consistency across documentation | |
check-version-consistency: | |
name: Check version consistency | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Run version consistency check | |
run: .github/scripts/check_version_consistency.py |