Interactive setup for Python LSP development environment
Sets up Pyright LSP and essential Python tools (ruff, black, mypy, pytest) for your project. Use this when starting Python development or adding LSP support to an existing codebase.
/plugin marketplace add zircote/python-lsp/plugin install python-lsp@zircote-lspThis command will configure your Python development environment with Pyright LSP and essential tools.
First, verify Python is installed:
python --version || python3 --version
npm install -g pyright
Or with pip:
pip install pyright
Quick install (all recommended tools):
pip install ruff black isort mypy bandit pytest pip-audit
Or install individually:
# Linting & Formatting
pip install ruff # Fast linter and formatter
pip install black # Code formatter
pip install isort # Import sorter
# Type Checking
pip install mypy # Static type checker
# Security
pip install bandit # Security linter
pip install pip-audit # Dependency auditor
# Testing
pip install pytest # Testing framework
# Check Pyright
pyright --version
# Check Ruff
ruff --version
# Check Black
black --version
# Check Mypy
mypy --version
pyproject.toml:
[tool.pyright]
pythonVersion = "3.11"
typeCheckingMode = "standard"
[tool.ruff]
line-length = 88
target-version = "py311"
[tool.black]
line-length = 88
target-version = ['py311']
[tool.isort]
profile = "black"
export ENABLE_LSP_TOOL=1
Test the LSP integration:
# Create a test file
echo 'def greet(name: str) -> str: return f"Hello, {name}"' > test_lsp.py
# Run type check
pyright test_lsp.py
# Clean up
rm test_lsp.py
Set the Python path in pyrightconfig.json:
{
"pythonVersion": "3.11",
"venvPath": ".",
"venv": ".venv"
}
Ensure your virtual environment is activated before running Claude Code:
source .venv/bin/activate
claude