Skip to content

James Williams

How to configure a python script as the default build task in VS Code

This snippet goes in your .vscode/tasks.json file. It will run the current python file as the default build task.

  • command will invoke the python interpreter that is configured in your workspace settings.
  • group will make this task the default build task.
  • presentation:focus will focus the terminal window when the task is run.
  • presentation:reveal will reveal the terminal window when the task is run.

Change args to any python file if youā€™d like to run the same file each time.

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Python: current file",
      "type": "shell",
      "command": "${command:python.interpreterPath}",
      "args": ["${file}"],
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "presentation": {
        "focus": true,
        "reveal": "always"
      },
      "options": {
        "cwd": "${workspaceFolder}"
      }
    }
  ]
}

Introducing bulletproof-python

I owe a debt of gratitude to Claudio Jolowicz for introducing me to modern python tooling. His Hypermodern Python template and associated blog series are a great resource.

The Hypermodern system is built around nox and poetry.

  • nox is similar in spirit to tox but uses python scripts instead of configuration files.
  • Itā€™s very powerful, but since Iā€™m not particularly clever, I find the hypermodern stack difficult to understand.

I decided to throw together a simple template that uses tox and pip-tools. The template uses:

It strives to be clean, simple and hard to break, albeit incomplete and likely suitable only for small libraries without broad distribution.

šŸŒ± The template is available here: bulletproof-python.

TIL about AlDente by AppHouseKitchen

The ā€˜optimize battery chargingā€™ feature in macOS has never worked well for me. It tends to stay at 100%, which is not great for my battery.

I recently discovered AlDente by AppHouseKitchen. Itā€™s a paid app that allows you to set a maximum charge level for your battery. There is a free tier I believe, but I almost always eat the paid versions of apps that I like and use.

Iā€™ve been using it for a few days now and itā€™s been working great. If youā€™re similarly annoyed by macOSā€™s battery charging behavior, I highly recommend it. Not a sponsored post, just a (so far) happy user.

Hello World

Welcome to my shiny new blog.

*slaps roof* This baby can hold so many posts. Check out /about for more information about me, and expect more meaningful content in 2023 as I embark on my open source journey.