Skip to content

[python] Introduce Mypy Typechecking #20

[python] Introduce Mypy Typechecking

[python] Introduce Mypy Typechecking #20

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python
on:
push:
branches:
- master
paths:
- .github/actions/setup-python/action.yml
- .github/workflows/python.yml
- .python-version
- requirements.txt
- requirements.lock
- pyproject.toml
- python/**/*.py
pull_request:
paths:
- .github/actions/setup-python/action.yml
- .github/workflows/python.yml
- .python-version
- requirements.txt
- requirements.lock
- pyproject.toml
- python/**/*.py
permissions:
contents: read
pull-requests: read
jobs:
change-detection:
runs-on: ubuntu-latest
outputs:
python-changes: ${{ steps.change-detection.outputs.python }}
steps:
- uses: actions/checkout@v6
- name: Change Detection
uses: dorny/paths-filter@v4
id: change-detection
with:
filters: |
python:
- .github/actions/setup-python/action.yml
- .github/workflows/python.yml
- .python-version
- requirements.txt
- requirements.lock
- pyproject.toml
- python/**/*.py
flake8:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: change-detection
if: needs.change-detection.outputs.python-changes == 'true'
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-python
- name: flake8
working-directory: ./python
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
unittest:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: change-detection
if: needs.change-detection.outputs.python-changes == 'true'
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-python
- name: UnitTest
working-directory: ./python
run: python -m unittest discover ./test
mypy:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: change-detection
if: needs.change-detection.outputs.python-changes == 'true'
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-python
- name: mypy
working-directory: ./python
run: mypy .