-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure pyright to work with pyenv (#105)
* Ignore pyrightconfig in gitignore * Configure pyright to work with pyenv in makefile * Add ruff config for trunk
- Loading branch information
1 parent
dae2faf
commit ce70848
Showing
6 changed files
with
62 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Generic, formatter-friendly config. | ||
select = ["B", "D3", "E", "F"] | ||
|
||
# Never enforce `E501` (line length violations). This should be handled by formatters. | ||
ignore = ["E501"] | ||
|
||
[lint] | ||
ignore-init-module-imports = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env bash | ||
set -e | ||
|
||
# Get the name of the expected venv for this repo from the pyproject.toml file. | ||
venv_name=$(grep -m 1 venv pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) || true | ||
|
||
# Check if pyrightconfig already exists. | ||
if [[ ! -f pyrightconfig.json ]]; then | ||
# Check if pyenv-pyright plugin is installed | ||
if ! command -v pyenv &>/dev/null; then | ||
echo "pyenv not installed. Please install pyenv..." | ||
exit 1 | ||
fi | ||
|
||
# Check if pyenv-pyright plugin is installed | ||
if ! command -v pyenv pyright &>/dev/null; then | ||
echo "pyenv-pyright not installed. Installing..." | ||
pyenv_root=$(pyenv root) | ||
git clone https://github.com/alefpereira/pyenv-pyright.git "${pyenv_root}"/plugins/pyenv-pyright | ||
fi | ||
|
||
# Generate the pyrightconfig.json file. | ||
pyenv pyright "${venv_name}" | ||
pyenv local "${venv_name}" | ||
|
||
fi | ||
|
||
# Check whether required keys are present in pyrightconfig.json. | ||
if ! jq -r --arg venv_name "${venv_name}" '. | select(.venv != $venv_name) | select(.venvPath != null)' pyrightconfig.json; then | ||
echo "Failed to configure pyright to use pyenv environment '${venv_name}' as interpreter. Please check pyrightconfig.json..." | ||
exit 1 | ||
fi | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,14 @@ | |
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml | ||
version: 0.1 | ||
cli: | ||
version: 1.20.1 | ||
version: 1.21.0 | ||
|
||
# Trunk provides extensibility via plugins. | ||
# (https://docs.trunk.io/plugins) | ||
plugins: | ||
sources: | ||
- id: trunk | ||
ref: v1.4.4 | ||
ref: v1.4.5 | ||
uri: https://github.com/trunk-io/plugins | ||
|
||
# Many linters and tools depend on runtimes - configure them here. | ||
|
@@ -34,34 +34,40 @@ lint: | |
enabled: | ||
- [email protected] | ||
- [email protected] | ||
- black@23.1.0 | ||
- [email protected].34 | ||
- black@24.3.0 | ||
- [email protected].44 | ||
- git-diff-check | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- osv-scanner@1.6.2 | ||
- osv-scanner@1.7.0 | ||
- [email protected]: | ||
commands: | ||
- end-of-file-fixer | ||
- check-json | ||
- detect-aws-credentials | ||
- [email protected] | ||
- [email protected].294 | ||
- [email protected].2 | ||
- [email protected].355 | ||
- [email protected].4 | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- trivy@0.49.1 | ||
- trufflehog@3.69.0 | ||
- trivy@0.50.0 | ||
- trufflehog@3.70.3 | ||
- [email protected] | ||
|
||
actions: | ||
disabled: | ||
- trunk-announce | ||
- trunk-check-pre-push | ||
- trunk-announce | ||
enabled: | ||
- trunk-check-pre-commit | ||
- configure-pyright-with-pyenv | ||
- trunk-fmt-pre-commit | ||
- trunk-upgrade-available | ||
definitions: | ||
- id: configure-pyright-with-pyenv | ||
run: source .trunk/configure-pyright-with-pyenv.sh | ||
triggers: | ||
- git_hooks: [pre-commit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters