This document explains the devcontainer setup for instructors and advanced users.
The following extensions are automatically installed in the Codespace to help students learn Python:
-
ms-python.python - Microsoft's official Python extension
- Provides IntelliSense, linting, debugging, and code navigation
- Essential for Python development
-
ms-python.vscode-pylance - Advanced language server
- Provides fast, feature-rich language support
- Includes type checking and code analysis
-
ms-python.debugpy - Python debugger
- Allows students to set breakpoints and step through code
- Essential for learning debugging skills
-
ms-python.black-formatter - Black Python formatter
- Automatically formats Python code to follow best practices
- Enforces consistent style (88 character line length)
- Works with format-on-save feature
-
esbenp.prettier-vscode - Prettier formatter
- Formats non-Python files (JSON, Markdown, etc.)
- Ensures consistent formatting across all file types
- littlefoxteam.vscode-python-test-adapter - Python Test Explorer
- Visual interface for running tests (beaker icon in sidebar)
- Makes it easy to see which tests pass/fail
- Automatically discovers pytest tests
-
njpwerner.autodocstring - Auto Docstring
- Helps generate docstrings for functions
- Teaches students proper documentation practices
-
streetsidesoftware.code-spell-checker - Spell Checker
- Catches typos in code, comments, and strings
- Helps students write clean, professional code
Note: The Environment Manager extension was removed as VS Code's built-in Python extension already provides environment selection in the status bar.
To ensure students learn without AI assistance, the following are disabled:
- GitHub Copilot
- IntelliSense auto-complete suggestions
- Inline suggestions
- Word-based suggestions
- Parameter hints during typing
Students must type code themselves and think through problems independently.
- Bracket Pair Colorization - Makes matching brackets easier to see
- Bracket Pair Guides - Shows vertical lines connecting bracket pairs
- 88-character Ruler - Helps students learn Black's line length standard
- Whitespace Rendering - Shows spaces/tabs at boundaries
- Files auto-save after 1 second of inactivity
- Format on Save enabled - Code is automatically formatted when you save
- Black formatter for Python (88 character line length)
- Prettier formatter for other file types
- Reduces risk of lost work and teaches proper formatting
- Auto Test Discovery - Tests are automatically found when files are saved
- pytest Integration - Built-in pytest support with visual test runner
- Basic Type Checking - Alerts students to potential type errors
- Helps catch bugs before running code
- 4-space indentation - Python standard
- No minimap - Reduces clutter for beginners
- Light theme - Default comfortable theme
When a student opens the Codespace:
- Python 3.12 environment is created
- All extensions are installed automatically
- Dependencies from
requirements.txtare installed - Student can start coding immediately
You can customize the devcontainer by editing .devcontainer/devcontainer.json:
- Add/remove extensions
- Change settings
- Modify the postCreateCommand
- Add additional dependencies to requirements.txt
To add an extension, find its ID from the VS Code marketplace and add it to the extensions array.
All VS Code settings can be customized in the settings section of devcontainer.json.
This template uses Python 3.12, which is the latest stable version as of 2024. You can change this by modifying the image in devcontainer.json:
"image": "mcr.microsoft.com/devcontainers/python:3.11"Students can add more Python packages by:
- Adding them to
requirements.txt - Running
pip install -r requirements.txtin the terminal - Or running
pip install package-namedirectly
The devcontainer will automatically install requirements.txt on startup.