在将列(int)转换为int时,Pyright显示出错误

发布于 2025-02-11 16:33:13 字数 311 浏览 2 评论 0原文

我不能不添加#类型而分配一个变量:忽略||用于Pyright(AutoComplete)或它给我一个错误。 错误:[pyright reportgeneraltypeissues] [e]类型“列”的参数无法分配给function“ in function” in function“ ___init__”                 /代码> (我使用Sqlalchemy BTW)

I can not assign a variable without adding # type:ignore || Used for pyright (Autocomplete) or it giving me an error.
Error: [Pyright reportGeneralTypeIssues] [E] Argument of type "Column" cannot be assigned to parameter "id" of type "int" in function "__init__"   "Column" is incompatible with "int"
(Im using SQLAlchemy btw)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好菇凉咱不稀罕他 2025-02-18 16:33:13

我安装了PIP软件包sqlalchemy-stubs对此有所帮助。

https://github.com/dropbox/sqlalchemy-stubs

I installed the pip package sqlalchemy-stubs which helped with this.

https://github.com/dropbox/sqlalchemy-stubs

决绝 2025-02-18 16:33:13

当您的扩展程序与程序中的某些变量类型无法正常工作时,您可以使用#type:imploore

它只能在其范围内起作用,因此...

# 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:imploore如果放入该程序的第一行在 global 范围中。

When your extension doesn't work fine with some variable types in the program, you can use # type: ignore.

It will work only in its scope, so...

# type: ignore
print(1 + 'x') # -> This won't throw errors

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

print(foo())

Instead...

def foo():
  # type: ignore
  return 2 + "!" # -> This one won't throw errors

print(foo())
print(1 + 'x') # -> This one will throw an error!

Working only in its scope, # type: ignore will have effect on the entire script if put in the first lines of the program, in the global scope.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文