Skip to content

Preserve original type for unannotated passthrough decorators (#2825) #2166

Preserve original type for unannotated passthrough decorators (#2825)

Preserve original type for unannotated passthrough decorators (#2825) #2166

Workflow file for this run

name: Run mypy_primer
on:
# Only run on PR, since we diff against master
pull_request:
paths:
- 'pyrefly/lib/**'
- 'pyrefly/third_party/**'
- '.github/workflows/mypy_primer.yml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
mypy_primer:
name: Run mypy_primer
runs-on: ubuntu-latest
strategy:
matrix:
shard-index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
fail-fast: false
timeout-minutes: 150
env:
PYREFLY_SCRIPTS_DIR: ${{ github.workspace }}/pyrefly_to_test/scripts
steps:
- uses: actions/checkout@v6
with:
path: pyrefly_to_test
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install -U pip
pip install git+https://github.com/hauntsaninja/mypy_primer.git
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2025-12-05
components: clippy, rustfmt
- name: Run mypy_primer
shell: bash
run: |
cd pyrefly_to_test
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
MERGE_BASE=$(git merge-base $GITHUB_SHA origin/$GITHUB_BASE_REF)
git checkout -b base_commit $MERGE_BASE
echo "base commit"
git rev-list --format=%s --max-count=1 base_commit
echo ''
cd ..
BASE_DIR=$(pwd)/primer_base
mkdir -p $BASE_DIR
# Build pyrefly for "new" commit and install wrapper
NEW_DIR=$BASE_DIR/pyrefly_new
mkdir -p $NEW_DIR
cd pyrefly_to_test && git checkout $GITHUB_SHA
CARGO_TARGET_DIR=$NEW_DIR/target cargo build --release --manifest-path pyrefly/Cargo.toml
BINARY_DIR=$NEW_DIR/target/release
mv $BINARY_DIR/pyrefly $BINARY_DIR/pyrefly-real
cp scripts/pyrefly_primer_wrapper.sh $BINARY_DIR/pyrefly
chmod +x $BINARY_DIR/pyrefly
# Build pyrefly for "old" commit and install wrapper
OLD_DIR=$BASE_DIR/pyrefly_old
mkdir -p $OLD_DIR
git checkout base_commit
CARGO_TARGET_DIR=$OLD_DIR/target cargo build --release --manifest-path pyrefly/Cargo.toml
BINARY_DIR=$OLD_DIR/target/release
mv $BINARY_DIR/pyrefly $BINARY_DIR/pyrefly-real
# Use the wrapper from the new commit (old commit may not have it)
git checkout $GITHUB_SHA -- scripts/pyrefly_primer_wrapper.sh
cp scripts/pyrefly_primer_wrapper.sh $BINARY_DIR/pyrefly
chmod +x $BINARY_DIR/pyrefly
cd ..
# fail action if exit code isn't zero or one
(
MYPY_PRIMER_NO_REBUILD=1 mypy_primer \
--repo pyrefly_to_test \
--base-dir $BASE_DIR \
--cargo-profile release \
--new $GITHUB_SHA --old base_commit \
--num-shards 15 --shard-index ${{ matrix.shard-index }} \
--debug \
--project-selector '^(?!.*(python/cpython|sympy/sympy))' \
--type-checker pyrefly \
--output concise \
| tee diff_${{ matrix.shard-index }}.txt
) || [ $? -eq 1 ]
- if: ${{ matrix.shard-index == 0 }}
name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- name: Upload mypy_primer diff + PR number
uses: actions/upload-artifact@v6
if: ${{ matrix.shard-index == 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: |
diff_${{ matrix.shard-index }}.txt
pr_number.txt
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v6
if: ${{ matrix.shard-index != 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: diff_${{ matrix.shard-index }}.txt
join_artifacts:
name: Join artifacts
runs-on: ubuntu-latest
needs: [mypy_primer]
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: mypy_primer_diffs
pattern: mypy_primer_diffs-*
delete-merged: true