Python 如何为<;指定类型提示;类别';类型'&燃气轮机;

Python 如何为<;指定类型提示;类别';类型'&燃气轮机;,python,mypy,Python,Mypy,我有一个函数,它的值是np.uint8。例如: import numpy as np def my_func(data_type): # do stuff # call my_func(np.uint8) data\u type的类型应该是什么?现在我理解了这个问题,可以编辑了 我想这就是你想要的: 该函数接受“联合”中任何类型的“类型” 你看,def my\u func(data\u type:type)?我想你不明白我的问题啊,是的,我没明白。您希望函数的输入采用np.uin

我有一个函数,它的值是
np.uint8
。例如:

import numpy as np

def my_func(data_type):
    # do stuff

# call
my_func(np.uint8)
data\u type
的类型应该是什么?

现在我理解了这个问题,可以编辑了

我想这就是你想要的:

该函数接受“联合”中任何类型的“类型”


你看,
def my\u func(data\u type:type)
?我想你不明白我的问题啊,是的,我没明白。您希望函数的输入采用np.uint8类型,而不是np.uint8类型的值吗?是的,这是正确的
import numpy as np
from typing import Union, Type

def my_func(data_type: Type[Union[np.uint8, np.uint16, ..., int64]]):
    # do stuff
    pass