Skip to content

Setting up VS Code

shell
cd ~
git clone git@github.com:nnja/python-for-pros.git
cd python-for-pros
shell
# Run uv sync to make sure a virtual env gets created
uv sync
uv run main.py
Text
# Open vs code in this directory
code .

Extensions

Install: - Python - Ruff - (Microsoft) mypy type checker

Info

Make sure that VS Code selects your correct Python environment, named learn-python when the window opens.

Open a terminal in VS Code, and let's run our first Python file again.

shell
uv run main.py                    

You should see Hello from learn-python!.

Ruff

Ruff catches things like: - unused imports - variables you forgot to use - formatting and style issues - a handful of common mistakes

Since you already installed the extension, add the following to your VS Code User settings (not project settings -- they get overwritten during exercises.)

JSON
{
  "[python]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.codeActionsOnSave": {
      "source.fixAll.ruff": "explicit",
      "source.organizeImports.ruff": "explicit"
    }
  }
}

We're going to set up VS Code to run ruff automatically when we save our files.