I have a Flask (v0.10.1) application using Flask-SQLAlchemy (v2.0) and I'm trying to configure Pylint to check it. Running with Python 3.4.2.
First error was:
Instance of 'SQLAlchemy' has no 'Table' member (no-member)
And I fixed this one ignoring the check for member attributes on SQLAlchemy:
ignored-classes=SQLAlchemy
But I'm having a problem with the query member on entities:
Class 'UserToken' has no 'query' member (no-member)
Is there any way to fix this issue without having to ignore no-member errors on every query call?
Flask bootstrap:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
app = Flask(__name__)
db.init_app(app)
app.run()
UserToken entity:
from app import db
class UserToken(db.Model):
user_token_id = db.Column(db.Integer, primary_key=True, index=True)
token_auth = db.Column(db.String(64), unique=True, nullable=False, index=True)
The controller:
from entities import UserToken
token = UserToken.query.filter(
UserToken.token_auth == token_hash,
).first()
pip install pylint-flask
pip install pylint-flask-sqlalchemy
Load the installed plugin.
For example, if you use VS code, please edit settings.json file as follows:
"python.linting.pylintArgs": ["--load-plugins", "pylint_flask_sqlalchemy", "pylint_flask"]
If having other warnings, define remaining members in generated-members
in pylintrc
file.