Skip to content
Latchkey

pyright workflow (pypa/setuptools)

The pyright workflow from pypa/setuptools, explained and optimized by Latchkey.

B

CI health: B - good

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: pypa/setuptools.github/workflows/pyright.ymlLicense MITView source

What it does

This is the pyright workflow from the pypa/setuptools repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# Split workflow file to not interfere with skeleton
name: pyright

on:
  merge_group:
  push:
    branches-ignore:
    # temporary GH branches relating to merge queues (jaraco/skeleton#93)
    - gh-readonly-queue/**
    tags:
    # required if branches-ignore is supplied (jaraco/skeleton#103)
    - "**"
  pull_request:
  workflow_dispatch:

concurrency:
  group: >-
    ${{ github.workflow }}-
    ${{ github.ref_type }}-
    ${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

env:
  # pin pyright version so a new version doesn't suddenly cause the CI to fail,
  # until types-setuptools is removed from typeshed.
  # For help with static-typing issues, or pyright update, ping @Avasam
  #
  # An exact version from https://github.com/microsoft/pyright/releases or "latest"
  PYRIGHT_VERSION: "1.1.385"

  # Environment variable to support color support (jaraco/skeleton#66)
  FORCE_COLOR: 1

  # Suppress noisy pip warnings
  PIP_DISABLE_PIP_VERSION_CHECK: "true"
  PIP_NO_PYTHON_VERSION_WARNING: "true"
  PIP_NO_WARN_SCRIPT_LOCATION: "true"

jobs:
  pyright:
    strategy:
      # https://blog.jaraco.com/efficient-use-of-ci-resources/
      matrix:
        python:
          - "3.10"
          - "3.14"
        platform:
          - ubuntu-latest
    runs-on: ${{ matrix.platform }}
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
          allow-prereleases: true
      - name: Install typed dependencies
        run: python -m pip install -e .[core,type]
      - name: Inform how to run locally
        run: |
          echo 'To run this test locally with npm pre-installed, run:'
          echo '> npx -y pyright@${{ env.PYRIGHT_VERSION }} --threads'
          echo 'You can also instead install "Pyright for Python" which will install npm for you:'
          if [ '$PYRIGHT_VERSION' == 'latest' ]; then
            echo '> pip install -U'
          else
            echo '> pip install pyright==${{ env.PYRIGHT_VERSION }}'
          fi
          echo '> pyright --threads'
        shell: bash
      - name: Run pyright
        uses: jakebailey/pyright-action@v2
        with:
          version: ${{ env.PYRIGHT_VERSION }}
          python-version: ${{ matrix.python }}
          extra-args: --threads

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

# Split workflow file to not interfere with skeleton
name: pyright
 
on:
  merge_group:
  push:
    branches-ignore:
    # temporary GH branches relating to merge queues (jaraco/skeleton#93)
    - gh-readonly-queue/**
    tags:
    # required if branches-ignore is supplied (jaraco/skeleton#103)
    - "**"
  pull_request:
  workflow_dispatch:
 
concurrency:
  group: >-
    ${{ github.workflow }}-
    ${{ github.ref_type }}-
    ${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true
 
env:
  # pin pyright version so a new version doesn't suddenly cause the CI to fail,
  # until types-setuptools is removed from typeshed.
  # For help with static-typing issues, or pyright update, ping @Avasam
  #
  # An exact version from https://github.com/microsoft/pyright/releases or "latest"
  PYRIGHT_VERSION: "1.1.385"
 
  # Environment variable to support color support (jaraco/skeleton#66)
  FORCE_COLOR: 1
 
  # Suppress noisy pip warnings
  PIP_DISABLE_PIP_VERSION_CHECK: "true"
  PIP_NO_PYTHON_VERSION_WARNING: "true"
  PIP_NO_WARN_SCRIPT_LOCATION: "true"
 
jobs:
  pyright:
    strategy:
      # https://blog.jaraco.com/efficient-use-of-ci-resources/
      matrix:
        python:
          - "3.10"
          - "3.14"
        platform:
          - ubuntu-latest
    runs-on: ${{ matrix.platform }}
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: ${{ matrix.python }}
          allow-prereleases: true
      - name: Install typed dependencies
        run: python -m pip install -e .[core,type]
      - name: Inform how to run locally
        run: |
          echo 'To run this test locally with npm pre-installed, run:'
          echo '> npx -y pyright@${{ env.PYRIGHT_VERSION }} --threads'
          echo 'You can also instead install "Pyright for Python" which will install npm for you:'
          if [ '$PYRIGHT_VERSION' == 'latest' ]; then
            echo '> pip install -U'
          else
            echo '> pip install pyright==${{ env.PYRIGHT_VERSION }}'
          fi
          echo '> pyright --threads'
        shell: bash
      - name: Run pyright
        uses: jakebailey/pyright-action@v2
        with:
          version: ${{ env.PYRIGHT_VERSION }}
          python-version: ${{ matrix.python }}
          extra-args: --threads
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job (2 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow