Is your feature request related to a problem? Please describe.
There are already some files using the new syntax for annotations.
https://github.com/Project-MONAI/MONAI/search?q=from+__future__+import+annotations
The old type aliases from the typing module are deprecated starting with python 3.9,
so to be future-prove it makes sense to migrate to the new style.
Describe the solution you'd like
Use from __future__ import annotations in all source files using annotations, so we have consistent usage (and not only in ~5 files).
The new annotations are also more readable e.g. Optional[Union[List[str], str]] vs. list[str] | str | None.
Secondly, this issue includes changing from typing import Callable, Sequence, ... to from collections.abc import Callable, Sequence, ... since the ones in the typing module are deprecated. They are interchangable even for isinstance checks (see also this stackoverflow thread).
Additional context
Is your feature request related to a problem? Please describe.
There are already some files using the new syntax for annotations.
https://github.com/Project-MONAI/MONAI/search?q=from+__future__+import+annotations
The old type aliases from the
typingmodule are deprecated starting with python 3.9,so to be future-prove it makes sense to migrate to the new style.
Describe the solution you'd like
Use
from __future__ import annotationsin all source files using annotations, so we have consistent usage (and not only in ~5 files).The new annotations are also more readable e.g.
Optional[Union[List[str], str]]vs.list[str] | str | None.Secondly, this issue includes changing
from typing import Callable, Sequence, ...tofrom collections.abc import Callable, Sequence, ...since the ones in thetypingmodule are deprecated. They are interchangable even forisinstancechecks (see also this stackoverflow thread).Additional context