Skip to content

MyPy issue #8149

@KumoLiu

Description

@KumoLiu
mypy 1.12.0 (compiled: yes)
monai/data/utils.py:562:17: error: Item "ItemsView[Any, Any]" of "Union[Iterator[tuple[Any, Any]], ItemsView[Any, Any], enumerate[Any]]" has no attribute "__next__"  [union-attr]
monai/transforms/utils.py:1130:25: error: Incompatible types in assignment (expression has type "Union[int, float, Any]", target has type "int")  [assignment]
monai/transforms/utils.py:1131:23: error: Incompatible types in assignment (expression has type "Union[int, float, Any]", target has type "int")  [assignment]
monai/transforms/croppad/functional.py:194:17: error: Incompatible types in assignment (expression has type "Union[Any, Size]", variable has type "list[Any]")  [assignment]
monai/transforms/utility/dictionary.py:738:23: error: Item "Hashable" of "Union[Any, Collection[Hashable], Hashable]" has no attribute "__iter__" (not iterable)  [union-attr]
monai/transforms/io/array.py:503:30: error: "str" not callable  [operator]
monai/transforms/io/array.py:507:35: error: Incompatible types in assignment (expression has type "Union[Any, ImageWriter]", variable has type "None")  [assignment]
monai/metrics/utils.py:206:20: error: Incompatible return value type (got "Union[tuple[Any, Any], tuple[Any, Any, Any, Any]]", expected "tuple[NdarrayTensor, NdarrayTensor]")  [return-value]
monai/bundle/reference_resolver.py:245:21: error: Item "dict_items[Any, Any]" of "Union[Iterator[tuple[Any, Any]], dict_items[Any, Any], enumerate[Any]]" has no attribute "__next__"  [union-attr]
monai/bundle/reference_resolver.py:247:13: error: Incompatible types in "yield" (actual type "tuple[Union[Any, int], str, Any]", expected type "tuple[str, str, Any]")  [misc]
monai/apps/deepgrow/dataset.py:159:45: error: Argument 1 to "sum" has incompatible type "Optional[Any]"; expected "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]]]"  [arg-type]
monai/apps/deepgrow/dataset.py:178:35: error: Item "None" of "Optional[Any]" has no attribute "flatten"  [union-attr]
tests/test_resample_backends.py:36:80: error: List item 4 has incompatible type "tuple[int, int, int, int]"; expected "Union[tuple[int, int, int], str, dict[str, Optional[str]], type[floating[Any]], type[floating[Any]]]"  [list-item]
tests/test_resample_backends.py:41:60: error: List item 1 has incompatible type "Union[type[int], type[float], type[floating[Any]], type[floating[Any]]]"; expected "Union[tuple[int, int, int], str, dict[str, Optional[str]], type[floating[Any]], type[floating[Any]]]"  [list-item]
tests/test_resample_backends.py:42:60: error: List item 1 has incompatible type "Union[type[int], type[float], type[floating[Any]], type[floating[Any]]]"; expected "Union[tuple[int, int, int], str, dict[str, Optional[str]], type[floating[Any]], type[floating[Any]]]"  [list-item]
tests/test_resample_backends.py:42:82: error: List item 4 has incompatible type "tuple[int, int, int, int]"; expected "Union[tuple[int, int, int], str, dict[str, Optional[str]], type[floating[Any]], type[floating[Any]]]"  [list-item]
monai/apps/pathology/transforms/post/dictionary.py:406:47: error: Argument 2 to "__call__" of "GenerateInstanceCentroid" has incompatible type "Optional[Any]"; expected "Union[Sequence[int], int]"  [arg-type]
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:241:12: error: Unsupported operand types for % ("int" and "Sequence[int]")  [operator]
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:241:12: note: Right operand is of type "Union[Any, Sequence[int], int]"
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:242:23: error: Unsupported operand types for * ("int" and "Sequence[int]")  [operator]
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:242:23: note: Both left and right operands are unions
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:242:24: error: Unsupported operand types for // ("int" and "Sequence[int]")  [operator]
monai/apps/generation/maisi/networks/autoencoderkl_maisi.py:242:24: note: Right operand is of type "Union[Any, Sequence[int], int]"
tests/test_trt_compile.py:84:13: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
Found 20 errors in 11 files (checked 1199 source files)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions