January 19, 2023

A Special Tool for Special Occasions: The Git Worktree Command

What is the issue? Working with branches is fine, as long as you are able to work on one only, or at least have the time to wrap up your work and commit some self-contained and complete state before switching to the next branch. If you cannot complete your work, it gets messy. Now, you can either use git stash create a work-in-progress(WIP) commit just keep the modified or new files, and try to work around them and to not commit them by accident git clone your repository into another directory I have done all of them, and they all have their downsides....

January 18, 2023

Your First Contribution to CPython

Do you love Python? I certainly do. Have you ever thought how cool it would be to contribute to it? Sounds scary? It is not! Python, or more specifically CPython as the reference implementation of the Python programming language is called, is an open source project like any other - nothing magical. Other resources While there are many great resources out there to prepare you for the first contribution, such as...

July 18, 2022

Just Enough Bazaar to Be Dangerous

Last year I wrote a blog post about how to migrate away from Bazaar, a distributed version control system, originally developed by Canonical, to git. While I still think this is the only way forward, here, at Canonical, working in the Launchpad team, we still have a couple of Bazaar repositories around, which cannot be easily migrated, as they are both integrated into deployment processes, and used by other teams....

June 27, 2022

Ubuntu Versions Cheat Sheet

about versions, names, even more versions and dates version code name python go debhelper end of standard support eol 14.04 trusty tahr 2.7.5 + 3.4 ? 9 04/2019 04/2024 16.04 xenial xerus 3.5 ? 9 04/2021 04/2026 18.04 bionic beaver 3.6 ? 11 04/2023 04/2028 20.04 focal fossa 3.8 1.13 + 1.14 12 04/2025 04/2030 22....

June 1, 2022

Oh Open Source Supply Chain Security, Where Art Thou?

“This is horrifying. But also not surprising.” These are the words of a friend of mine, a security specialist, when I told him what I found out today. But first… What is Open Source Supply Chain? Most applications nowadays use open source libraries, especially for common functionality like e.g. sending web requests, so it is not necessary to re-invent the wheel all the time. This is great! This saves a lot of work, time and money, and usually when a library is widely used, it is rock stable....

May 23, 2022

Conda, Miniconda and 2x Anaconda

While I certainly heard of Conda, Miniconda, and Anaconda before, I only had a vague idea of these terms and what is behind them. So, let’s get the terminology straight. Conda… what? Conda Conda is a CLI application which does package, dependency and environment management, not only for Python, but also for other languages. Anaconda Anaconda is an open-source Python distribution platform. This is the all-in-one package, containing not only the Conda application, but already many packages which you usually need for a data science project....

April 16, 2022

getattr() Considered Harmful

While Hynek already considered “Considered Harmful” was getting old in 2016, and so he named this blog post hasattr() – A Dangerous Misnomer, instead of hasattr() considered harmful, meanwhile it is 2022 and I still like that phrase. So here we go… getattr() considered harmful The setting is a CLI application with 100% test coverage, and even branch coverage is activated. coverage 101 I assume you know what coverage is. 100% test coverage means that the test suite covers all lines of code of your library or application....

November 30, 2021

Testing Argparse Applications - the Better Way

When you are creating command line applications in Python, you probably heard of argparse, which is a great library for exactly doing this, and it is even included in Python’s standard library. Imagine you have created the following argparse application: <main.py> import argparse def main(): parser = argparse.ArgumentParser() parser.add_argument('--name', required=True) args = parser.parse_args() print(f'Hello {args.name}') if __name__ == '__main__': sys.exit(main()) Looks straightforward, works great, but at one point, you certainly want to add tests for it, right?...

November 21, 2021

Combine Coverage for Different Python Versions

Is it enough to run code coverage for a single Python version? Probably, but not necessarily. Especially when you still need to support Python 2.7 (sigh), there could be quite some different code paths for Python 2 and Python 3. A simple example… try: import Queue # Python 2 except ImportError: import queue as Queue # Python 3 But also the different Python 3 versions may require that you not only test your code for each interpreter, but also you need to assess code coverage for the different versions, and certainly you want to make sure you got all paths covered....

November 9, 2021

Bye-Bye python-memcached, hello pymemcache

For one app that I help maintaining I noticed that python-memcached was used, which has not been updated in several years. There were some efforts to transfer python-memcached to a new maintainer, but at the end that did not work out. So, the project is dead. While an unmaintained project may currently work, there are several things to consider: there may be bugs which do not get fixed there may be security issues which do not get fixed it may stop working for e....