Recent Posts (Page 3)

Why does Python log a DeprecationWarning saying “invalid escape sequence”?

Invalid essssscape sssssequence...

Take this code, which prints a shruggy man:

Read more...

Git: How to undo commits

Just press here to undo!

To errr is human, to undo computer can help.

Read more...

Git: How to automatically create upstream branches

That’s a serious number of branches.

You started a new feature branch, worked hard on initial commits, and you’re ready to send it for review. You try to push and:

Read more...

Git: How to clean up squash-merged branches

Squishity-squashity-merge.

Git hosts offer a “squash merge” option that merges a reviewed branch by combining all its commits into one. This leads to a linear Git history on your main branch, which is easier to understand and refer back to code reviews.

Read more...

Git: How to alias “master” as “main”

Don’t tangle up those branches!

The Git community is gradually moving the default branch name from “master” to “main”, because the term “master” is hurtful to some people as it refers to slavery.

Read more...

Git: How to enable autocorrect

I think you meant Qe5!

By default, if you mistype a Git command, it will list similar commands that you might have meant:

Read more...

django-upgrade Mega Release 1.11.0

Some busy bees have contributed their fixes.

I just released version 1.11.0 of django-upgrade, a tool for automatically upgrading your Django project code. This release contains a lot of new features and fixes, thanks to new contributors including those at the Djangocon Europe sprints. Let’s look at the top changes.

Read more...

Python Type Hints - How to use Mypy’s always-true boolean check detection

Redundant-looking science apparatus

Sometimes code uses boolean checks on variables that can only be true. This is normally a sign of a mistake, either in the type hints or the implementation. Mypy has an optional check that can find such problematic boolean usage with its truthy-bool error code.

Read more...

Git: How to show and copy commit SHA’s

SHA me the way!

You can use git rev-parse to show the SHA of the current Git commit:

Read more...

Use WARMED to evaluate software engineering practices

This teapot is very warmed!

In a lecture titled Where Does Bad Code Come From?, Casey Muratori introduced the acronym WARMED for categorizing the costs of code:

Read more...