Add Github Action to run mypy / reorder-python-imports / black on all PRs (#251)

Also fixes import ordering (previously, local imports weren't grouped together as they should have been)
This commit is contained in:
Chris Weaver
2023-07-29 16:53:38 -07:00
committed by GitHub
parent 87fe6f7575
commit 132a9f750d
51 changed files with 265 additions and 143 deletions

41
.github/workflows/pr-python-checks.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Python Checks
on:
pull_request:
branches: [ main ]
jobs:
mypy-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
backend/requirements/default.txt
backend/requirements/dev.txt
- run: |
python -m pip install --upgrade pip
pip install -r backend/requirements/default.txt
pip install -r backend/requirements/dev.txt
- name: Run MyPy
run: |
cd backend
mypy .
- name: Check import order with reorder-python-imports
run: |
cd backend
find ./danswer -name "*.py" | xargs reorder-python-imports --py311-plus
- name: Check code formatting with Black
run: |
cd backend
black --check .