Skip to content

Commit

Permalink
ci(typeannotation): GitHub action to check files changed in a PR
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Jun 6, 2024
1 parent 2649467 commit 7fdb144
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PR type annotation

on:
pull_request:
paths:
- 'datasalad/**.py'
- '!**/tests/**.py'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
# run on a "fresh" python, but see mypy flag to check for the oldest supported version
python-version: 3.12
architecture: x64
- name: Checkout
uses: actions/checkout@v4
- name: Install mypy
run: python -m pip install mypy # you can pin your preferred version
- name: Get Python changed files
id: changed-py-files
uses: tj-actions/changed-files@v44
with:
files: |
*.py
**/*.py
- name: Type check changed files
if: steps.changed-py-files.outputs.any_changed == 'true'
run: |
# get any type stubs that mypy thinks it needs
mypy --install-types --non-interactive --follow-imports skip ${{ steps.changed-py-files.outputs.all_changed_files }}
# run mypy on the modified files only, and do not even follow imports.
# this results is a fairly superficial test, but given the overall
# state of annotations, we strive to become more correct incrementally
# with focused error reports, rather than barfing a huge complaint
# that is unrelated to the changeset someone has been working on.
# run on the oldest supported Python version
mypy --python-version 3.8 --follow-imports skip --pretty --show-error-context ${{ steps.changed-py-files.outputs.all_changed_files }}

0 comments on commit 7fdb144

Please sign in to comment.