Say you’re writing a typed Python package with a function head that takes a generic tuple and returns the first element. How do you implement it for type safety? Below, we’ll take inspiration from Alexis King’s Parse, Don’t Validate blog post1 and statically typed languages like Haskell and OCaml to help us avoid potential runtime errors in Python. The Naive Solution Let’s just return the first element2: def head(t: tuple[T, .