Mypy annotation for any type but None

Viewed 700

How can I annotate a type that can be anything but None? In other words, this type is Any but is not None.

1 Answers

You can do Union[int, str, ...] but exclude None from that union.

Related