小编pal*_*apa的帖子

我可以在 Pylance 中禁用第三方包的类型错误吗?

我使用的一些包没有类型提示它们的代码,所以当我使用它们时,Pylance 不断告诉我我使用的函数有部分未知的类型,这是我无法解决的问题。有没有办法禁用此类错误?

python type-hinting python-typing pylance

14
推荐指数
1
解决办法
593
查看次数

类型错误:“numpy._DTypeMeta”对象不可订阅

我正在尝试输入ndarray像这样的 numpy 提示:

RGB = numpy.dtype[numpy.uint8]
ThreeD = tuple[int, int, int]

def load_images(paths: list[str]) -> tuple[list[numpy.ndarray[ThreeD, RGB]], list[str]]: ...
Run Code Online (Sandbox Code Playgroud)

但在我运行此命令的第一行时,出现以下错误:

RGB = numpy.dtype[numpy.uint8]
TypeError: 'numpy._DTypeMeta' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

如何ndarray正确输入提示a?

python numpy type-hinting type-alias python-typing

11
推荐指数
3
解决办法
5万
查看次数

一个 constexpr 函数,用于计算 std::vector 的嵌套深度

有没有办法编写一个 constexpr 函数来返回 std::vector 的嵌套深度?

例子:

get_vector_nested_layer_count<std::vector<std::vector<int>>>() // 2
get_vector_nested_layer_count<std::vector<std::vector<std::vector<float>>>>() // 3
Run Code Online (Sandbox Code Playgroud)

c++ templates constexpr constexpr-function

6
推荐指数
2
解决办法
386
查看次数