Skip to content

New numpy(1.21.0) raised many typehint issues #2418

@Nic-Ma

Description

@Nic-Ma

Describe the bug

mypy 0.902
monai/handlers/utils.py:225:32: error: Cannot call function of unknown type  [operator]
monai/handlers/utils.py:227:32: error: Cannot call function of unknown type  [operator]
monai/data/utils.py:611:29: error: Argument 1 to "eye" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "int"  [arg-type]
monai/transforms/utils.py:229:70: error: Argument 3 to "copypaste_arrays" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Sequence[int]"  [arg-type]
monai/transforms/utils.py:229:86: error: Argument 4 to "copypaste_arrays" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Sequence[int]"  [arg-type]
monai/transforms/utils.py:321:41: error: Incompatible default for argument "rand_state" (default has type Module, argument has type "RandomState")  [assignment]
monai/transforms/utils.py:605:58: error: Incompatible default for argument "rand_state" (default has type Module, argument has type "RandomState")  [assignment]
monai/transforms/intensity/array.py:82:23: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[floating[_64Bit]]]", variable has type "None")  [assignment]
monai/transforms/intensity/array.py:142:24: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[floating[_64Bit]]]", variable has type "None")  [assignment]
monai/transforms/intensity/array.py:143:24: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[floating[_64Bit]]]", variable has type "None")  [assignment]
monai/transforms/intensity/array.py:479:97: error: Argument "coeff" to "_generate_random_field" of "RandBiasField" has incompatible type "ndarray[Any, dtype[floating[_64Bit]]]"; expected "Tuple[int, ...]"  [arg-type]
monai/transforms/intensity/array.py:677:28: error: Incompatible types in assignment (expression has type "float", variable has type "None")  [assignment]
monai/transforms/spatial/array.py:467:46: error: Argument 2 to "create_translate" has incompatible type "ndarray[Any, dtype[floating[Any]]]"; expected "Union[Sequence[float], float]"  [arg-type]
monai/transforms/spatial/array.py:476:48: error: Argument 2 to "create_translate" has incompatible type "ndarray[Any, dtype[floating[Any]]]"; expected "Union[Sequence[float], float]"  [arg-type]
monai/transforms/spatial/array.py:1000:22: error: Incompatible types in assignment (expression has type "Union[ndarray[Any, Any], Tensor]", variable has type "ndarray[Any, Any]")  [assignment]
monai/transforms/spatial/array.py:1003:22: error: Incompatible types in assignment (expression has type "Tensor", variable has type "ndarray[Any, Any]")  [assignment]
monai/transforms/spatial/array.py:1007:22: error: "ndarray[Any, Any]" has no attribute "to"  [attr-defined]
monai/transforms/spatial/array.py:1009:17: error: "ndarray[Any, Any]" has no attribute "float"; maybe "flat"?  [attr-defined]
monai/transforms/spatial/array.py:1145:30: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[floating[_64Bit]]]", variable has type "float")  [assignment]
monai/transforms/spatial/array.py:1711:32: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[floating[_64Bit]]]", variable has type "None")  [assignment]
monai/transforms/spatial/dictionary.py:1524:43: error: Argument "zoom" to "Zoom" has incompatible type "ndarray[Any, dtype[floating[Any]]]"; expected "Union[Sequence[float], float]"  [arg-type]
monai/transforms/spatial/dictionary.py:1652:47: error: Argument "zoom" to "Zoom" has incompatible type "ndarray[Any, dtype[floating[Any]]]"; expected "Union[Sequence[float], float]"  [arg-type]
monai/data/synthetic.py:54:13: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:55:13: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:56:15: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:61:37: error: "object" has no attribute "random"  [attr-defined]
monai/data/synthetic.py:63:29: error: "object" has no attribute "random"  [attr-defined]
monai/data/synthetic.py:67:12: error: "object" has no attribute "uniform"  [attr-defined]
monai/data/synthetic.py:117:13: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:118:13: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:119:13: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:120:15: error: "object" has no attribute "randint"  [attr-defined]
monai/data/synthetic.py:125:37: error: "object" has no attribute "random"  [attr-defined]
monai/data/synthetic.py:127:29: error: "object" has no attribute "random"  [attr-defined]
monai/data/synthetic.py:131:12: error: "object" has no attribute "uniform"  [attr-defined]
tests/utils.py:163:12: error: "object" has no attribute "choice"  [attr-defined]
tests/utils.py:164:17: error: "object" has no attribute "choice"  [attr-defined]
Found 37 errors in 8 files (checked 599 source files)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions