Skip to main content
Glass provides comprehensive Python support with automatic virtual environment detection, multiple LSP server options, and extensive test framework integration.

LSP Servers

Glass supports multiple Python language servers:
A faster fork of Pyright with improved performance:
  • Full type checking
  • Intelligent completions
  • Go-to-definition and references
  • Automatic import suggestions
  • Inlay hints for types
Installed automatically from npm.

Virtual Environment Detection

Glass automatically detects and uses Python virtual environments:

Detection Methods

Glass detects these virtual environments automatically:
  • venv: Standard library python -m venv
  • virtualenv: Third-party tool
  • Poetry: poetry install environments
  • Pipenv: pipenv install environments
  • uv: Modern Python package manager
  • Conda/Mamba: Anaconda environments
  • Pixi: Modern package manager
Priority order (most specific first):
  1. UV workspace environments
  2. UV project environments
  3. Poetry environments
  4. Pipenv environments
  5. venv/virtualenv
  6. Conda environments

Environment Priority

For workspaces with multiple packages:
project/
├── .venv              # Root environment
├── backend/
│   └── .venv          # Backend environment (higher priority)
└── frontend/
    └── node_modules/
Glass prefers the environment closest to the current file:
  1. Same directory as file
  2. Parent directories (closest first)
  3. Workspace root
Glass uses Python Environment Tools (PET) for environment detection, the same library used by VS Code.

Features

Intelligent Completions

data = [1, 2, 3]
data.| # Shows list methods with signatures
Completions include:
  • Method signatures with parameter types
  • Return type annotations
  • Docstrings

Custom Completion Sorting

Glass customizes Pyright’s completion order:
class MyClass:
    public_field: str         # Priority 0 (public)
    _protected_field: int     # Priority 1 (protected)
    __private_field: bool     # Priority 2 (private)
    __init__(self):           # Priority 3 (dunder)
        pass
Within each visibility level, items are sorted by kind:
  1. Enum members
  2. Fields
  3. Properties
  4. Variables
  5. Constants
  6. Methods/Functions
  7. Classes
  8. Modules

Test Framework Integration

Glass provides built-in support for Python test frameworks:

Test Runner Selection

Configure your preferred test runner:
{
  "languages": {
    "Python": {
      "tasks": {
        "variables": {
          "TEST_RUNNER": "pytest"  // or "unittest"
        }
      }
    }
  }
}

pytest (Default)

Run all tests in a file:
python3 -m pytest test_example.py
Glass automatically uses the active virtual environment’s Python.

unittest (Standard Library)

python3 -m unittest tests/test_example.py

Module Execution

Run Python files as modules:
# mypackage/cli.py
if __name__ == "__main__":
    main()
Task: Run module ‘mypackage.cli’
python3 -m mypackage.cli
Glass automatically converts file paths to module names:
  • src/mypackage/cli.pysrc.mypackage.cli
  • mypackage/cli.pymypackage.cli

Task Variables

VariableDescriptionExample
PYTHON_ACTIVE_ZED_TOOLCHAINActive Python interpreter/path/to/.venv/bin/python3
PYTHON_TEST_TARGETTest target (pytest or unittest format)test_file.py::TestClass::test_method
PYTHON_MODULE_NAMEModule name from file pathmypackage.cli

Available Tasks

  • Execute selection: Run selected code
  • Run file: Execute entire Python file
  • Run module: Run file as module with -m

Configuration

Language Server Configuration

{
  "lsp": {
    "pyright": {
      "settings": {
        "python": {
          "analysis": {
            "typeCheckingMode": "strict",
            "autoImportCompletions": true,
            "diagnosticMode": "workspace"
          }
        }
      }
    }
  }
}
Type checking modes:
  • off: No type checking
  • basic: Basic type checking (default)
  • strict: Strict type checking

Workspace Detection

Glass detects Python projects by finding pyproject.toml:
[tool.poetry]
name = "myproject"
version = "0.1.0"

[tool.poetry.dependencies]
python = "^3.11"
This helps Glass:
  • Find the project root
  • Detect package structure
  • Configure relative imports

Conda/Mamba Support

For Conda environments:
Configure Conda manager preference:
{
  "terminal": {
    "detect_venv": {
      "on": {
        "conda_manager": "auto"  // or "conda", "mamba", "micromamba"
      }
    }
  }
}
Glass will activate Conda environments in integrated terminals.

Troubleshooting

If the language server can’t find imports, ensure your virtual environment includes all dependencies:
# Recreate environment
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
pip install -r requirements.txt
Then restart Glass or run “Python: Restart Language Server”.
Check detected Python:
  1. Cmd/Ctrl+Shift+P → “Python: Show Detected Environments”
  2. Verify the correct environment is selected
  3. If not, use “Python: Select Interpreter”
Or check manually:
which python3
python3 --version

Next Steps

Build docs developers (and LLMs) love