pytest-sphinx icon indicating copy to clipboard operation
pytest-sphinx copied to clipboard

Write union types as X | Y (PEP 604)

Open twmr opened this issue 3 years ago • 2 comments

twmr avatar Sep 08 '22 17:09 twmr

Friendlier typing syntax seems to be a carrot for deprecating old python releases.

In my tmuxp project, I still support python 3.7, so have to use Union, Optional, etc.

In my libvcs project, it's python 3.9+, I can use str | None instead of Optional[None] and int | str instead of Union[int, str]. It's so much cleaner.

tony avatar Sep 09 '22 00:09 tony

At work we are also using python3.7 and thx to the __future__ import we can use e.g. the PEP604 type annotations, but I was not aware that this doesn't work at runtime.

twmr avatar Sep 13 '22 14:09 twmr