首页 > 解决方案 > Pycharm中令人困惑的类型提示警告

问题描述

谁能解释为什么 Pycharm 会在这里发出类型警告?

import numpy as np

def test(arr: np.ndarray) -> tuple:
    to_return = np.where((arr > 0.1) & (arr < 0.9))
    return to_return  # marks the text with "Expected type 'tuple', got 'ndarray' instead"


a = np.random.rand(10, 10)

res = test(a)


print(type(res))  #<class 'tuple'>

标签: python-3.xnumpypycharm

解决方案


推荐阅读