我有一个关于上的MacBook预期类型 '{__name__}',得到了 '() - >无',而不是
我写了一个函数我的Python(3.6)代码或PyCharm IDE问题使用 “timeit” 测试其他功能花费的时间
def timeit_func(func_name, num_of_round=1):
print("start" + func_name.__name__ + "()")
str_setup = "from __main__ import " + func_name.__name__
print('%s() spent %f s' % (func_name.__name__,
timeit.timeit(func_name.__name__ + "()",
setup=str_setup,
number=num_of_round)))
print(func_name.__name__ + "() finish")
参数“func_name”只是一个需要测试的功能,并且已经被定义。 我调用这个函数的代码
if __name__ == "__main__":
timeit_func(func_name=another_function)
功能运作良好,但pycharm表明,此代码“FUNC_NAME = another_function”的信息:
Expected type '{__name__}', got '() -> None' instead less... (⌃F1 ⌥T)
This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations
我用Google搜索“预期类型'{名}',得到了“() - >无”,但一无所获helpful.I是Python的新。 我想问一下这是什么意思?我该如何让这些信息消失?因为现在它突出了,让我感到不舒服。
我通过import time
使用它在Python3.6,这就是我在timeit模块()(timeit.timeit()
)
def timeit(stmt="pass", setup="pass", timer=default_timer, number=default_number, globals=None):
"""Convenience function to create Timer object and call timeit method."""
return Timer(stmt, setup, timer, globals).timeit(number)
是什么'timeit.timeit()'函数..? –
这是一个众所周知[问题](https://youtrack.jetbrains.com/issue/PY-21408),其功能不匹配对'{__name __}'型。 – user2235698