如果不添加# type:ignore || Used for pyright (Autocomplete)或它给了我一个错误,我就不能给变量赋值。错误:[Pyright reportGeneralTypeIssues] [E] Argument of type "Column" cannot be assigned to parameter "id" of type "int" in function "__init__" "Column" is incompatible with "int" (我在使用SQLAlchemy btw)
发布于 2022-06-28 09:48:02
当您的扩展不能很好地处理程序中的一些变量类型时,您可以使用# type: ignore。
它只在它的范围内起作用,所以.
# type: ignore
print(1 + 'x') # -> This won't throw errors
def foo():
return 2 + "!" # -> Neither this one will throw errors!
print(foo())而是..。
def foo():
# type: ignore
return 2 + "!" # -> This one won't throw errors
print(foo())
print(1 + 'x') # -> This one will throw an error!# type: ignore只在其作用域内工作,如果将其放在程序的第一行(全局范围)中,则会对整个脚本产生影响。
https://stackoverflow.com/questions/72783758
复制相似问题