Skip to content

numpy-1.22.0 introduced new typehints errors #3561

Closed
@Nic-Ma

Description

@Nic-Ma

Is your feature request related to a problem? Please describe.
As numpy updated to 1.22.0, it introduced new errors:

mypy 0.930
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for <= ("int" and "generic")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for <= ("int" and "complex")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for <= ("int" and "str")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for <= ("int" and "bytes")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for <= ("int" and "memoryview")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: note: Right operand is of type "Union[generic, bool, int, float, complex, str, bytes, memoryview]"
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for >= ("int" and "generic")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for >= ("int" and "complex")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: error: Unsupported operand types for >= ("int" and "memoryview")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:16: note: Left operand is of type "Union[generic, bool, int, float, complex, str, bytes, memoryview]"
monai/transforms/utils_pytorch_numpy_unification.py:104:26: error: Unsupported operand types for <= ("str" and "int")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:104:26: error: Unsupported operand types for <= ("bytes" and "int")  [operator]
monai/transforms/utils_pytorch_numpy_unification.py:137:22: error: Incompatible types in assignment (expression has type "Tuple[ndarray[Any, dtype[signedinteger[Any]]], ...]", variable has type "Union[ndarray[Any, Any], Tensor]")  [assignment]
monai/transforms/utility/array.py:794:24: error: Cannot call function of unknown type  [operator]
monai/transforms/utility/array.py:797:24: error: Cannot call function of unknown type  [operator]
monai/transforms/intensity/array.py:456:9: error: Returning Any from function declared to return "Union[ndarray[Any, Any], Tensor]"  [no-any-return]
monai/transforms/intensity/array.py:596:9: error: Returning Any from function declared to return "Union[ndarray[Any, Any], Tensor]"  [no-any-return]
monai/transforms/spatial/array.py:197:43: error: Argument 2 to "zoom_affine" has incompatible type "ndarray[Any, dtype[floating[_64Bit]]]"; expected "Sequence[float]"  [arg-type]
monai/transforms/spatial/array.py:704:32: error: Cannot call function of unknown type  [operator]
monai/transforms/spatial/array.py:1383:20: error: Item "ndarray[Any, dtype[floating[Any]]]" of "Union[Any, ndarray[Any, dtype[floating[Any]]], Tensor]" has no attribute "permute"  [union-attr]
monai/transforms/spatial/array.py:1383:44: error: Item "ndarray[Any, dtype[floating[Any]]]" of "Union[Any, ndarray[Any, dtype[floating[Any]]], Tensor]" has no attribute "ndimension"  [union-attr]
monai/apps/pathology/transforms/spatial/array.py:63:17: error: Returning Any from function declared to return "Union[ndarray[Any, Any], Tensor]"  [no-any-return]
monai/apps/datasets.py:153:24: error: Argument 1 to "randomize" of "MedNISTDataset" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "List[int]"  [arg-type]
monai/apps/datasets.py:361:24: error: Argument 1 to "randomize" of "DecathlonDataset" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "List[int]"  [arg-type]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions