Skip to content

Conversation

@philippasdev
Copy link
Contributor

Integrate pyrefly static type checker into the development workflow
with both local make targets and CI automation.

Changes:

  • Add pyrefly>=0.1.0 to dev dependency group in pyproject.toml
  • Add 'make typecheck' target to run pyrefly check --summarize-errors
  • Integrate 'pyrefly init' into 'make setup' workflow
  • Create GitHub Actions workflow for automated type checking on PRs
  • Update Makefile help text to include type checking commands

The pyrefly configuration in pyproject.toml excludes common non-code
directories (node_modules, pycache, venv)

Summary

This PR integrates Pyrefly static type checking into the DNAstack client library development workflow, enabling automated type error detection during development and CI.

What is Pyrefly?

Pyrefly is a fast type checker and language server for Python that helps catch type-related bugs before runtime. It improves code quality through type annotations that serve as living documentation and enables safer refactoring.

Changes

Development Dependencies

  • Added pyrefly>=0.1.0 to the dev dependency group in pyproject.toml
  • Configured pyrefly to exclude common non-code directories (node_modules, __pycache__, *venv)

Local Development

  • New Make target: make typecheck - Runs pyrefly check --summarize-errors for local type checking
  • Setup integration: make setup now includes pyrefly init to initialize the type checker
  • Updated help documentation: Added "Linting & Type Checking" section to make help

CI/CD

  • New GitHub Actions workflow: .github/workflows/typecheck.yml
    • Triggers on pull requests to main branch
    • Manual triggering via workflow_dispatch
    • Uses pinned action versions for security (matching existing workflows)
    • Leverages uv caching for fast builds
    • Runs make typecheck for consistency with local development

Benefits

  • Catch bugs early: Identify type-related errors during development rather than at runtime
  • Improve code quality: Type annotations serve as living documentation
  • Safer refactoring: Type checking ensures changes don't introduce type mismatches
  • Better IDE support: Enhanced autocomplete and refactoring tools
  • Team collaboration: Clearer contracts between functions and modules

Usage

Local Development

# Run type checking
make typecheck

# Setup includes pyrefly initialization
make setup

Pre-commit Workflow

# Recommended checks before committing
make lint && make test-unit && make typecheck

CI Integration

Type checking runs automatically on all pull requests to main and can be manually triggered via the GitHub Actions UI.

Documentation

- Pyrefly Documentation: https://pyrefly.org/en/docs/
- Installation Guide: https://pyrefly.org/en/docs/installation/

Test plan

- Run make setup to verify pyrefly initialization works
- Run make typecheck to verify type checking executes successfully
- Verify GitHub Actions workflow runs on PR creation
- Check that make help displays the new typecheck command
- Confirm pyrefly is installed as part of dev dependencies via uv sync --group dev

  Integrate pyrefly static type checker into the development workflow
  with both local make targets and CI automation.

  Changes:
  - Add pyrefly>=0.1.0 to dev dependency group in pyproject.toml
  - Add 'make typecheck' target to run pyrefly check --summarize-errors
  - Integrate 'pyrefly init' into 'make setup' workflow
  - Create GitHub Actions workflow for automated type checking on PRs
  - Update Makefile help text to include type checking commands

  The pyrefly configuration in pyproject.toml excludes common non-code
  directories (node_modules, __pycache__, venv)
@platform-automation-dnastack

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
10407 5700 55% 30% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 3307013 by action🐍

Comment on lines +10 to +35
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4

- name: Install uv
uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Set up Python
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
with:
python-version: '3.11'

- name: Install package and dependencies
run: |
uv sync --group dev

- name: Run Pyrefly Type Checker
run: |
make typecheck

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To fix this issue, we need to add a permissions: block to the workflow YAML file, specifying the minimum required permissions for the GITHUB_TOKEN. Because the workflow only performs read-only operations, the lowest practical permission is to set contents: read either at the workflow root or at the job level. It is best practice to place it at the workflow root so all jobs in this workflow inherit the reduced permission unless they explicitly override it. The change should be made in .github/workflows/typecheck.yml by inserting a block like:

permissions:
  contents: read

directly after the name: declaration (or above the first on: block for clarity), ensuring that only read access to repository contents is granted for all jobs in the workflow.

Suggested changeset 1
.github/workflows/typecheck.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml
--- a/.github/workflows/typecheck.yml
+++ b/.github/workflows/typecheck.yml
@@ -1,4 +1,6 @@
 name: Pyrefly Type Check
+permissions:
+  contents: read
 
 on:
   pull_request:
EOF
@@ -1,4 +1,6 @@
name: Pyrefly Type Check
permissions:
contents: read

on:
pull_request:
Copilot is powered by AI and may make mistakes. Always verify output.
@omairvalence omairvalence removed their request for review January 16, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants