Skip to content

James Williams

P.S. I'm not active on social media. If you liked this, add this page to your RSS reader or subscribe via email and I'll send you a quick note when I post something new.


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.


Note: The original version of this post incorrectly stated that Poetry does not play nice with pip-installs from git source. This is not the case; I simply had my pyproject.toml file incorrectly configured to use setuptools instead of poetry-core as the build backend.

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.

# Here's some code
print("Hello World")