Narrow state of a Django model using Python TypeGuard

Today, I came across a problem with type checking in a Django project which led me to use TypeGuard for the first time. I've heard about them in TypeScript on the Syntax podcast , so I was aware of the concept, but never had a practical situation where I needed to use them in Python. The problem So I was doing some refactoring to eliminate a bit of code duplication between 3 functions. As features…