Skip to content
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

Add doc readme for tying version to pre-commit #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.