PyCharm warns about unexpected arguments for SQLAlchemy User model

会有一股神秘感。 提交于 2021-01-27 06:43:39

问题


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")

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


回答1:


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.



来源:https://stackoverflow.com/questions/58936116/pycharm-warns-about-unexpected-arguments-for-sqlalchemy-user-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!