Skip to content

typing error with torch 1.12 #4606

Description

@wyli

Describe the bug

mypy 0.961 (compiled: yes)
monai/data/box_utils.py:624:5: error: Returning Any from function declared to return "Union[ndarray[Any, Any], Tensor]"  [no-any-return]
monai/transforms/utility/array.py:316:23: error: Incompatible types in assignment (expression has type "List[ndarray[Any, dtype[Any]]]", variable has type "List[Tensor]")  [assignment]
monai/transforms/utility/array.py:319:16: error: Incompatible return value type (got "List[Tensor]", expected "List[Union[ndarray[Any, Any], Tensor]]")  [return-value]
monai/transforms/utility/array.py:319:16: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
monai/transforms/utility/array.py:319:16: note: Consider using "Sequence" instead, which is covariant
monai/transforms/utility/array.py:319:16: note: Perhaps you need a type annotation for "outputs"? Suggestion: "List[Union[ndarray[Any, Any], Tensor]]"
monai/networks/blocks/feature_pyramid_network.py:196:42: error: Argument 1 to "kaiming_uniform_" has incompatible type "Union[Tensor, Module]"; expected "Tensor"  [arg-type]
Found 4 errors in 3 files (checked 869 source files)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions