-
Notifications
You must be signed in to change notification settings - Fork 0
[CU-86b6u16q5] Add pyrefly type checking to development workflow #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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)
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
| 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
Show autofix suggestion
Hide autofix suggestion
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.
-
Copy modified lines R2-R3
| @@ -1,4 +1,6 @@ | ||
| name: Pyrefly Type Check | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: |
Integrate pyrefly static type checker into the development workflow
with both local make targets and CI automation.
Changes:
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
pyrefly>=0.1.0to thedevdependency group inpyproject.tomlnode_modules,__pycache__,*venv)Local Development
make typecheck- Runspyrefly check --summarize-errorsfor local type checkingmake setupnow includespyrefly initto initialize the type checkermake helpCI/CD
.github/workflows/typecheck.ymlmainbranchworkflow_dispatchmake typecheckfor consistency with local developmentBenefits
Usage
Local Development