Step 3 VS Code extensions for Python coursework
Three extensions turn VS Code from a text editor into a Python-aware environment. Open the
Extensions panel with Ctrl+Shift+X (Windows, Linux) or Cmd+Shift+X (macOS), then install
each one below.
Python (Official Extension by Microsoft)
The Python extension adds full Python support to VS Code. It lets you run code, debug
programs, manage virtual environments, run tests, and work with Jupyter notebooks. Without
it, VS Code treats .py files as plain text.
Pylance (Official Extension by Microsoft)
Pylance works alongside the Python extension and provides the language intelligence layer.
Install it for autocomplete, parameter hints, auto-imports, and go-to-definition across
your project. The type checking mode (off / basic / strict) is set in Python > Analysis: Type Checking Mode. The basic level catches the common bugs without blocking
progress on assignments that don't yet have full type annotations.
Key features: autocomplete, parameter suggestions, auto-imports, go-to-definition, find
references, rename symbols across a project, hover documentation, and DocString
generation.
Ruff (charliermarsh.ruff)
Ruff is a fast linter and formatter for Python written in Rust. A linter analyzes source
code to flag potential bugs, unused imports, and style violations before the code runs. A
formatter restructures code for consistency (indentation, spacing, line lengths, import
ordering), following PEP 8 without changing behavior. The VS Code extension runs both on
save, so the file is clean before you commit it.
Key features: style issue detection, unused import and variable detection, automatic
formatting, import sorting, and quick fixes for common problems.
Turn on type checking
Pylance ships with three modes: off, basic, strict. Set Python > Analysis: Type Checking Mode to basic. Strict mode is satisfying once you trust your
types; basic catches the bugs.
Drop this into .vscode/settings.json
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.terminal.activateEnvironment": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
},
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["tests"],
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true
}
}
On Windows, swap .venv/bin/python for .venv\Scripts\python.exe. Commit this file to the repo so anyone cloning the project gets the same editor
behavior; the .gitignore snippet at the bottom keeps everything
except settings.json out.