43

I'm currently trying to implement steam login into website. But I'm unable to get pass this error within the code. I've created the database object but it keeps showing the error I mentioned earlier. I'm not sure whether SQLAlchemy has changed or what since I used it.

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
db = SQLAlchemy(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)

The message emitted by pylint is

E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)
2

6 Answers 6

71

EDIT: After read and try np8's answer my previous answer is wrong there is a package you have to install, which is pylint_flask_sqlalchemy

so the answer will be

on your project directory find folder .vscode (if you dont have it, just create it) then create file settings.json and add this line

{
    # You have to put it in this order to make it works
    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint_flask_sqlalchemy",
        "pylint_flask",                 # This package is optional
    ]
}

You also need to have pylint-flask-sqlalchemy and if you want to use pylint-flask install on your current python environment:

pip install pylint-flask-sqlalchemy
pip install pylint-flask
6
  • Thanks mate, I already had a .vscode/settings.json, just added this vars and worked like a charm... Sep 11, 2020 at 12:04
  • Thanks. it works. This answer should be mark as answer.
    – Derick
    Oct 27, 2020 at 15:25
  • This cannot work. The load module contains dashes which will result in error. You are completely disabling pyling in vscode.
    – bmakan
    Oct 29, 2020 at 7:17
  • 1
    Is this config missing a comma after "pylint_flask_sqlalchemy"?
    – Nick.Mc
    Nov 29, 2020 at 0:30
  • For me, it's "pylint-flask-sqlalchemy". Works on Python 3.9.
    – ibnɘꟻ
    Jan 15, 2021 at 2:50
21
pip install pylint-flask

In case of Visual Studio Code: Open File > Preferences > Settings > Edit in settings.json as below:

"python.linting.pylintArgs": ["--load-plugins", "pylint_flask"]
3
  • 6
    For me, this doesn't work, but the following line does: "python.linting.pylintArgs": ["--load-plugins", "pylint-flask"] Nov 22, 2019 at 9:04
  • 1
    For me, this only worked when I entered it into my user settings: Command Palette: Preferences: Open Settings (JSON)
    – Brian
    Jan 19, 2020 at 20:02
  • I also had to enable "python.jediEnabled": true, in order for the pylint_flask plugin to properly figure out scoped_session.add, scoped_session.commit members. I'm not sure why. Perhaps because I have my language server set to "jedi" via "python.languageServer": "Jedi",. Jan 1, 2021 at 16:49
19

Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type in one of the following commands:

Python: Select Linter

Switch from PyLint to flake8 or other supported linters.

1
19

Summary of working and non-working configurations

It seems that this can be configured so many ways incorrectly, that I decided to write the different options down. I am assuming VS Code, but for command line or other editor, arguments and their order is the same. These were tested using the latest versions of all the packages (list in the bottom of this post)

Working versions

# What you'll need is pylint_flask_sqlalchemy
"python.linting.pylintArgs": ["--load-plugins", "pylint_flask_sqlalchemy"]

# You can add pylint_flask but only if it is *AFTER* pylint_flask_sqlalchemy
"python.linting.pylintArgs": ["--load-plugins", "pylint_flask_sqlalchemy", "pylint_flask"]

Non-working versions

# pylint_flask does not help, but can break it (see below)
"python.linting.pylintArgs": ["--load-plugins", "pylint_flask"]

# You can NOT add pylint_flask *BEFORE* pylint_flask_sqlalchemy
"python.linting.pylintArgs": ["--load-plugins", "pylint_flask", "pylint_flask_sqlalchemy"]

# CAUTION: These will disable pylint silently altogether!
# Do not use dash (-) but underscore (_)!
"python.linting.pylintArgs": ["--load-plugins", "pylint-flask-sqlalchemy", "pylint-flask"]
"python.linting.pylintArgs": ["--load-plugins", "pylint-flask"]
"python.linting.pylintArgs": ["--load-plugins", "pylint-flask-sqlalchemy"]

Details for those who are interested

pylint_flask_sqlalchemy

The pylint-flask-sqlalchemy1 was created specifically to fix this2. You can enable it by adding it to --load-plugins of pylint. In command line this would be

python -m pylint --load-plugins pylint_flash_sqlalchemy <mymodule.py>

and in VS Code (Settings (JSON)):

"python.linting.pylintArgs": ["--load-plugins", "pylint_flask_sqlalchemy"]

1Also mirrored to GitHub: https://github.com/anybox/pylint_flask_sqlalchemy
2See this comment on pylint Issue tracker.

pylint_flask

pylint-flask is pylint plugin for Flask. It has nothing to do with Flask-SQLAlchemy and it does not even try to solve the false positive issues pylint has with Flask-SQLAlchemy3. The only possibility to use pylint-flask to "make the errors disappear" is to load it with erroneusly with dashes, which makes the whole pylint to be disabled.

It seems that pylint-flask must be loaded after pylint-flas-sqlalchemy; I tested with my setup, and for some reason

"python.linting.pylintArgs": ["--load-plugins", "pylint_flask", "pylint_flask_sqlalchemy"]

will not work, but

"python.linting.pylintArgs": ["--load-plugins", "pylint_flask_sqlalchemy", "pylint_flask"]

will. So the order of loading plugins matters.

3 See the code for yourself: pylint-flask source & pylint-flask-sqlaclhemy source

Caution: Do not remove your linting accidentally

As the documentation of pylint-flask and pylint-flask-sqlalchemy says, the names in the argument --load-plugins should be written with underscores; If you use

"python.linting.pylintArgs": ["--load-plugins", "pylint-flask", "pylint-flask-sqlalchemy"]

in VS Code, the errors will be gone, but so will be all of your linting as the pylint crashes silently in the background.

Installing pylint-flask-sqlalchemy

pip install pylint-flask-sqlalchemy

Used versions

Flask                   1.1.2  
Flask-SQLAlchemy        2.4.4 
pylint                  2.5.3
pylint-flask            0.6
pylint-flask-sqlalchemy 0.2.0

See also

1
  • 2
    This is the most complete answer and should be accepted. Order is critical Sep 1, 2020 at 17:43
13

I've just encountered this issue. Neither of the suggested solutions worked for me, but the following does.

First, install these modules:

pip install pylint-flask
pip install pylint-flask-sqlalchemy

Then, in Visual Studio Code, you need to add the following to your settings.json file:

"python.linting.pylintArgs": ["--load-plugins", "pylint-flask", "pylint-flask-sqlalchemy"]
1
  • 2
    TIP: If it doesn't seem to take effect, try reloading Visual Studio Code (Command Palette > Developer > Reload Window). Jul 19, 2020 at 6:47
6

For Windows, this works: In case of Visual Studio Code: Open File > Preferences > Settings > Edit in settings.json -> and add this code after comma below existing settings:

    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint-flask"
    ]
  1. First step
  2. Second step
1
  • Dashes in --load-module cause the pylint to crash and therefore disable it.
    – bmakan
    Oct 29, 2020 at 7:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.