Simplifying Unions in Python Type Hints
Python 3.10 has several new typing features. They are given in detail here:
PEP 604, Allow writing union types as X | Y
PEP 613, Explicit Type Aliases
PEP 612, Parameter Specification Variables
This tutorial focuses on talking about PEP 604, which makes writing union types easier when adding type annotation (AKA: type hinting) to your codebase.
Unions Ye Old…
Keep reading with a 7-day free trial
Subscribe to The Python Papers to keep reading this post and get 7 days of free access to the full post archives.