PyCharm 警告 SQLAlchemy 用户模型的意外参数

编程入门 行业动态 更新时间:2024-10-26 17:34:23
本文介绍了PyCharm 警告 SQLAlchemy 用户模型的意外参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在 PyCharm 中使用 Flask-SQLAlchemy.当我尝试通过将关键字参数传递给模型来创建我的 User 模型的实例时,PyCharm 会用意外参数"警告突出显示这些参数.当我创建其他模型的实例时,我没有收到此警告.为什么我的 User 模型会出现此错误?

I'm working with Flask-SQLAlchemy in PyCharm. When I try to create instances of my User model by passing keyword arguments to the model, PyCharm highlights the arguments with an "Unexpected argument(s)" warning. When I create instances of other models, I don't get this warning. Why am I getting this error for my User model?

class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) new_user = User(username="test")

在上面的示例中,username="test" 突出显示为警告.

In the above example username="test" is highlighted as a warning.

推荐答案

这是 PyCharm 中的一个错误,不是你的代码.使用 mixins 时,PyCharm 无法将列名识别为参数.您可以通过单击标题旁边的大拇指按钮来表达您对该问题的兴趣.在此之前,除了禁用检查或忽略突出显示之外,您无法解决此问题.

This is a bug in PyCharm, not your code. PyCharm doesn't recognize column names as arguments when using mixins. You can show your interest in the issue by clicking the thumbs up button next to its title. Until then, there's nothing you can do to fix the issue besides disabling the inspection or ignoring the highlighting.

更多推荐

PyCharm 警告 SQLAlchemy 用户模型的意外参数

本文发布于:2023-10-16 06:08:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496713.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   意外   参数   用户   PyCharm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!