Skip to content

Instantly share code, notes, and snippets.

@lsjostro
Last active August 31, 2022 13:23
Show Gist options
  • Save lsjostro/c0d6c74a066d5cf30fc56ba513bc32a7 to your computer and use it in GitHub Desktop.
Save lsjostro/c0d6c74a066d5cf30fc56ba513bc32a7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Summary: Create pyright config file in current directory
#
set -e
[ -n "$PYENV_DEBUG" ] && set -x
PYRIGHT_FILENAME='pyrightconfig.json'
create_new_file() {
new_file='{"venvPath":"'${VIRTUAL_ENV%/*}'", "venv":"'python-$PYENV_VERSION'"}'
echo "$new_file" >$PYRIGHT_FILENAME
}
if [ -n "$VIRTUAL_ENV" ] && [ -n "$PYENV_VERSION" ] && [ -n "$DIRENV_DIR" ]; then
create_new_file
exit 0
else
echo "No virtualenv found. Please activate a virtualenv with pyenv and direnv."
exit 1
fi
@lsjostro
Copy link
Author

install under ~/.pyenv/plugins/pyenv-pyright/bin/pyenv-pyright

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment