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 23, 2024
1 parent ab0f126 commit ffec71a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,35 @@ 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
version 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" )).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 ffec71a

Please sign in to comment.