Skip to content

Development: code style

Deborah Kaplan edited this page Feb 18, 2026 · 1 revision

Code style and linting

  • on PR, use black for reformatting, almost entirely bog-standard config except line length
  • on PR, use isort for import sorting
  • on PR, use mypy for type checking

Formatting and import sorting happen automatically, because we're enforcing them. Type checking will produce errors instead of auto-fixing, because they require developer input to resolve.

To run these commands locally on the shell

Just once, to get the new testing requirements:

pip install -r requirements.txt

Every time you want to check locally:

black .
isort .
mypy .

Enable automatic type checking in VS Code

If you're using Visual Studio Code:

  • install the extension matangover.mypy (link)
  • install the extension ms-python.black-formatter (link)
  • install the extension ms-python.vscode-pylance (link)
  • pip install -r requirements.txt in your VS Code requirements
  • add the following to your settings.json (merging with existing blocks as needed):
    "[python]": {
      "editor.formatOnType": true,
      "editor.defaultFormatter": "ms-python.black-formatter",
      "editor.formatOnSave": true,
      "editor.codeActionsOnSave": {
        "source.organizeImports": "explicit"
      }
    },
    "isort.args": ["--profile", "black"],
    "mypy.runUsingActiveInterpreter": true,

Clone this wiki locally