Skip to content

Commit

Permalink
Add "version: PATH" to pull pyright from $PATH (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Apr 11, 2024
1 parent a9434fd commit 32e0647
Show file tree
Hide file tree
Showing 11 changed files with 1,038 additions and 102 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ jobs:
- uses: ./
with:
working-directory: ./smoke-test

- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- run: pip install pyright

- uses: ./
with:
working-directory: ./smoke-test
version: PATH
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GitHub action for [pyright](https://github.com/microsoft/pyright). Featuring:
inputs:
# Options for pyright-action
version:
description: 'Version of pyright to run. If neither version nor pylance-version are specified, the latest version will be used.'
description: 'Version of pyright to run, or "PATH" to use pyright from $PATH. If neither version nor pylance-version are specified, the latest version will be used.'
required: false
pylance-version:
description: 'Version of pylance whose pyright version should be run. Can be latest-release, latest-prerelease, or a specific pylance version. Ignored if version option is specified.'
Expand Down Expand Up @@ -143,7 +143,31 @@ poetry's python binary is on `$PATH`:
- uses: jakebailey/pyright-action@v2
```

## Keeping Pyright and Pylance in sync
## Providing a pyright version sourced from preexisting dependencies

The `version` input only accepts "latest" or a specific version number. However,
there are many ways to use specify a version of `pyright` derived from other
tools.

### Using pyright from `$PATH`

If you have `pyright` installed in your environment, e.g. via the `pyright` PyPI
package, specify `version: PATH` to use the version that's on `$PATH`.

```yml
- run: |
python -m venv .venv
source .venv/bin/activate
pip install -r dev-requirements.txt # includes pyright
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
- uses: jakebailey/pyright-action@v2
with:
version: PATH
```

### Keeping Pyright and Pylance in sync

If you use Pylance as your language server, you'll likely want pyright-action to
use the same version of `pyright` that Pylance does. The `pylance-version`
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branding:
inputs:
# Options for pyright-action
version:
description: 'Version of pyright to run. If neither version nor pylance-version are specified, the latest version will be used.'
description: 'Version of pyright to run, or "PATH" to use pyright from $PATH. If neither version nor pylance-version are specified, the latest version will be used.'
required: false
pylance-version:
description: 'Version of pylance whose pyright version should be run. Can be latest-release, latest-prerelease, or a specific pylance version. Ignored if version option is specified.'
Expand Down
Loading

0 comments on commit 32e0647

Please sign in to comment.