首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pyright在将列( int )转换为int时显示了一个错误

Pyright在将列( int )转换为int时显示了一个错误
EN

Stack Overflow用户
提问于 2022-06-28 09:15:14
回答 1查看 282关注 0票数 0

如果不添加# 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)

EN

回答 1

Stack Overflow用户

发布于 2022-06-28 09:48:02

当您的扩展不能很好地处理程序中的一些变量类型时,您可以使用# type: ignore

它只在它的范围内起作用,所以.

代码语言:javascript
复制
# type: ignore
print(1 + 'x') # -> This won't throw errors

def foo():
  return 2 + "!" # -> Neither this one will throw errors!

print(foo())

而是..。

代码语言:javascript
复制
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只在其作用域内工作,如果将其放在程序的第一行(全局范围)中,则会对整个脚本产生影响。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72783758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档