Skip to content

#tutorial

  • Deprecate positional arguments with placeholders

    Python libraries usually alert users in advance, when they use arguments that will be removed in future versions. Using a simple placeholder as a temporary default value for deprecated arguments is often the simplest and most expressive way to implement this.

  • Test the stacklevel of Python warnings

    The stacklevel argument is important to determine which line of code is shown as the origin of a warning and how easy it is to understand its cause. If warnings are meant for your users, then they are part of your public API, and it is a good idea to check their origin in your test suite. Here’s how.

  • Restore a deleted label via GitHub's REST API

    When a GitHub label is deleted, it is removed from every issue and pull request that it was associated with. Unfortunately, it is not as easy to revert this action if the label was accidentally deleted. I recently had to figure out an automated way to restore the label for 100+ issues, as I certainly didn’t want to do so by hand. So here is a quick “how-to” in case you ever encounter a similar problem.