Exclude type in Python typing annotation

Python type hinting can’t exclude types. You can’t exclude Nones, strs or any another type.

The only thing you can use to try to emulate None exclusion is to use Union and write every type you are actually using in the dictionary.

Leave a Comment