Consistent usage of annotation syntax#5836
Conversation
|
There are some special cases, since these subscriptable types are only allowed as annotations but not inside casts. Therefore, |
|
thanks, could you please also review the pyupgrade configs |
I see! I believe it is better to ignore those typings instead of keeping a deprecated type. |
…ns`) and don't use deprecated typing aliases (instead use `collections.abc`) Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Behrooz <[email protected]>
24a9196 to
9f4c805
Compare
There was a problem hiding this comment.
I think we still need the deprecated types here, since the new ones only work inside annotations, but this is creating a type alias.
https://github.com/Shadow-Devil/MONAI/blob/9f4c8059491af22c7d89f02f8d8ed804206868e3/monai/transforms/spatial/array.py#L111
|
looks like it's feasible to ensure the Line 157 in 6060a47 could you please add this: |
Signed-off-by: Felix Schnabel <[email protected]>
…isort Signed-off-by: Felix Schnabel <[email protected]>
This now also adds the imports to |
|
/black |
Signed-off-by: monai-bot <[email protected]>
|
/build |
We have until 2025 to update this!😉 This behavior is accepted in 3.10 where we can define |
Fixes #5835.
Description
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 interchangeable even forisinstancechecks (see also this stackoverflow thread).Types of changes
./runtests.sh --quick --unittests --disttests.