Skip to content

Commit

Permalink
Add doc readme for tying version to pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Mar 18, 2024
1 parent ab0f126 commit 9e6164b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,34 @@ you'll want to set one or the other, not both.
with:
pylance-version: latest-release
```

## Keeping Pyright in sync with your project

If you use Pyright in your project out of the CI, chances are that the Pyright
is already specified somewhere. We'll try to share in this section recipes for
tying the version of Pyright used in the CI to the version used in your project.
Those are generic recipes that you may need to adapt to your project's needs.

### `pre-commit`

If you're using `https://github.com/RobertCraigie/pyright-python` or any other
pre-commit hook where the version of Pyright is the revision of the repo (with a
leading `v` character), you may use the following snippet:

```yaml
- name: Extract pyright version from pre-commit
id: pre-commit-pyright-version
run: |
yq '.repos
| select( .repo | contains("pyright" )).0.rev
| "pyright-version="+sub("^v", "")' \
.pre-commit-config.yaml >> $GITHUB_OUTPUT
- uses: jakebailey/pyright-action@v2
with:
version: ${{ steps.pre-commit-pyright-version.outputs.pyright-version }}
```

Feel free to contribute other recipes, such as for `pyproject.toml`
(poetry-style or PEP 621-style), `poetry.lock`, `pdm.lock`, `requirements.txt`
etc.

0 comments on commit 9e6164b

Please sign in to comment.