simple_ado
simple_ado copied to clipboard
Use types subscripts for type hints
These were introduced in Python 3.9 and are significantly more readable than the other version. Instead of having to do from typing import List
and then setting something like def foo() -> List[str]
, we can now just directly subscript list without an import: def foo() -> list[str]
.
We also have some syntactic sugar for type unions. This means what was Union[X, Y]
is now X | Y
. That also means Optional[X]
, which was a shorthand for Union[X, None]
is now X | None
.
These changes came in with Python 3.9. While we were supporting 3.8, 3.9 has been out for almost 4 years. We will need to bump our major version before we release this.
A secondary change made here was updating doc comments to remove the type information. This is redundant and therefore not necessary. i.e. :param str foo: Some foo description
is now just :param foo: Some foo description
since we know it's of type str
from the method signature.