Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLAlchemy intellisense #292

Closed
redeemefy opened this issue Nov 25, 2017 · 22 comments
Closed

SQLAlchemy intellisense #292

redeemefy opened this issue Nov 25, 2017 · 22 comments
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@redeemefy
Copy link

Environment data

VS Code version: 1.18.1
Python Extension version: 0.8.0
Python Version: 3.6.3
OS and version: 10.13.1

Actual behavior

code is not prompting with intellisense for sqlalchemy.
screen shot 2017-11-25 at 2 13 26 pm

Expected behavior

Steps to reproduce:

File structure

screen shot 2017-11-25 at 2 14 57 pm

In ./__init__.py

"""Blog main module"""
from flask import Flask
from flask_sqlalchemy import SQLAlchemy


app = Flask(__name__)
app.config.from_object('settings')
db = SQLAlchemy(app)

from blog import views
from author import views

In author/models.py

from flask_blog_code import db

class Author(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    fullname = db.Column(db.string(80))
    email = db.Column(db.String(35), unique=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(80))
    is_author = db.Column(db.Boolean)
    test = db.Co

User Settings

{
    "workbench.colorTheme": "Solarized Dark",
    "editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace",
    "editor.fontSize": 16,
    "editor.minimap.enabled": false,
    "workbench.startupEditor": "newUntitledFile",
    "python.pythonPath": "${wordspaceRoot}/venv/bin/python",
    "python.linting.flake8Path": "${workspaceRoot}/venv/bin/flake8",
    "python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Args": [
        "--disable=E402",
        "--max-line-length=120"
    ]
}

Logs

Output from Python output panel

Output from Console window (Help->Developer Tools menu)

@brettcannon brettcannon added awaiting 1-verification area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug labels Nov 27, 2017
@DonJayamanne
Copy link

@diazgilberto Please could you provide a sample repo for this.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed awaiting 1-verification labels Jan 18, 2018
@seven-share
Copy link

i have almost the same question.
ide show E1101:Instance of 'SQLAlchemy' has no 'Column' member
but it works

@DonJayamanne
Copy link

@seven-share if you have a sample repo, please upload it, so I can test this.

@rivasd
Copy link

rivasd commented Mar 2, 2018

I do not have a sample repo with non-sensitive code to upload, but I would like to confirm that I have this exact same issue and that it is definitely specific to the Flask-SQLAlchemy package

@ghost
Copy link

ghost commented Mar 7, 2018

You can get a sample repo to see the issue from the Flask Mega Tutorial Part IV : Database.
At the start of that page there is a link to a zip file you can download and see this happening...

The link is also here: https://github.com/miguelgrinberg/microblog/archive/v0.4.zip

Open the models.py file and you'll get the red underlines.. mouse over them and you get errors like:

[pylint] E1101:Instance of 'SQLAlchemy' has no 'String' member
[pylint] E1101:Instance of 'SQLAlchemy' has no 'String' member
etc..

I googled and found a post here:
https://stackoverflow.com/questions/28193025/pylint-cant-find-sqlalchemy-query-member

Following instructions there I made a pylintrc

$ pylint --generate-rcfile > pylintrc

Edited pylintrc and set

ignored-modules=flask_sqlalchemy

Closed and reopened models.py
Now the red underlines are gone away...

But I'm not sure this is a great solution... cos now pylint ignores anything to do with the db..

There is another solution on that thread that modifies something to do with pylint plugins... but its a bit beyond a python newbie like myself...

@ghost
Copy link

ghost commented Mar 7, 2018

Drat.... adding pylintrc didn't fix it...
Now when I open routes.py I get errors around:

db.session.add(user)
db.session.commit()

[pylint] E1101:Instance of 'scoped_session' has no 'add' member
[pylint] E1101:Instance of 'scoped_session' has no 'commit' member

@brettcannon
Copy link
Member

@pjatinsight there were some bugs around our .pylintrc detection that should be fixed in the next release.

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Mar 7, 2018
@ghost
Copy link

ghost commented Mar 8, 2018

Great work. Thanks.
Its just makin learning python a bit awkward for the moment.. can't get the debugger to run when pylint is unhappy...
But its free so I'm not complaining at all...

@brettcannon
Copy link
Member

@pjatinsight the new release went out just over an hour ago, so once the extension is updated to 2018.2.0 you should hopefully have this fixed for you.

@ghost
Copy link

ghost commented Mar 12, 2018

Thanks !

@ghost
Copy link

ghost commented Mar 12, 2018

Hi Brett,
Sorry, I' don't mean to be awkward.. I'm just trying to learn python by following the mega tutorial...
(as in the link above). I removed the pylintrc file and updated vscode.. and pylint etc..

With the new updated pylint.. I'm still getting a load of E1101 errors...in the models.py file...

Do I need to clear out some cache or something ?

Thanks PJ

E1101:Instance of 'SQLAlchemy' has no 'Column' member
E1101:Instance of 'SQLAlchemy' has no 'Integer' member
file: 'file:///Users/pj/Documents/Personal/Learning/python/microblog/app/models.py'
severity: 'Error'
message: 'E1101:Instance of 'SQLAlchemy' has no 'Column' member'
etc
etc

@ghost
Copy link

ghost commented Mar 12, 2018

... wondering now.. I have the python interpreter set to 2.7.10 in my virtualenvwrapper environment.
Would that be part of the problem?

@brettcannon
Copy link
Member

@pjatinsight I don't know SQLAlchemy to know well enough if that would potentially cause the issue with Python 2.7.10, but that is an old release so I would update anyway (and if you're trying to learn Python then do use Python 3 instead of Python 2).

@brettcannon
Copy link
Member

But since this is a Pylint issue I'm closing as an upstream problem.

@ghost
Copy link

ghost commented Mar 13, 2018

Thanks for your help Brett.
PJ

@anselal
Copy link

anselal commented May 8, 2018

Workaround. If you have the ms-python.python installed you actually change the linter from pylint to flake8 which is a better linter and the problem is gone.

To change the linter run the command Select Linter from the Command Palette.

I am using flake8 on all my projects without any problems so far ;)

Let me know if you are ok with this solution !!!

@KoduIsGreat
Copy link

KoduIsGreat commented Jun 6, 2018

I dont understand why this is closed, This issue is about vscode intellisense, not python linting, Even with trying other linters vscode still does not appropriately display intellisense for flask-sqlalchemy,

@anselal
Copy link

anselal commented Jun 6, 2018

@KoduIsGreat did you try changing your linter as I mention above ?

@KoduIsGreat
Copy link

Yes.
"Even with trying other linters vscode still does not appropriately display intellisense for flask-sqlalchemy,"

@patrys
Copy link

patrys commented Jun 6, 2018

@anselal I believe @KoduIsGreat is talking about the original issue (ie. autocomplete not working), not the comment about pylint (ie. things being underlined incorrectly).

@KoduIsGreat
Copy link

@patrys Yes thats correct. I think this was closed incorrectly. or should I just create a new issue.

"SQLAlchemy intellisense" is the name of this issue, I'm confused as to how we got onto a linting discussion in the first place lol.

@brettcannon
Copy link
Member

@KoduIsGreat please create a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

8 participants