question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intellisense not available for flask-sqlalchemy

See original GitHub issue

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: macOS High Sierra 10.13.6
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Relevant/affected Python packages and their versions: flask-sqlalchemy

Expected behaviour

Show intellisense option for Column

Actual behaviour

image

Steps to reproduce:

# services/users/project/__init__.py


import os
from flask import Flask, jsonify
from flask_sqlalchemy import SQLAlchemy


# instantiate the app
app = Flask(__name__)

# set config
app_settings = os.getenv('APP_SETTINGS')
app.config.from_object(app_settings)

# instantiate the db
db = SQLAlchemy(app)


# model
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    fullname = db.Column(db.String(80))

User Settings

{
    "editor.renderWhitespace": "all",
    "files.associations": {
        "*.txt": "tsv"
    },
    "editor.renderControlCharacters": false,
    "workbench.startupEditor": "newUntitledFile",
    "explorer.confirmDragAndDrop": false,
    "python.venvPath": "~/.virtualenvs",
    "python.jediEnabled": false,
    "git.autofetch": true,
    "git.confirmSync": false
}

Workspace Settings

{
    "python.pythonPath": "/Users/nick.perkins/.virtualenvs/testdriven-app/bin/python",
    "python.linting.pylintArgs": ["--load-plugins", "pylint_flask"]
}

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.75.0
Initializing for /Users/nick.perkins/.virtualenvs/testdriven-app/bin/python
Reloading modules... 
Reloading modules... 
done.
done.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Plazmiuscommented, Feb 7, 2019

I faced a similar issue. My first guess is that it is because attributes of class SQLAlchemy are initialized by setattr function (https://github.com/pallets/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L78-L81)

    for module in sqlalchemy, sqlalchemy.orm:
        for key in module.__all__:
            if not hasattr(obj, key):
                setattr(obj, key, getattr(module, key))

For example, Model is available: image However, Column is not: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Flask-SQLAlchemy doesn't have intellisense support?
When almost entire Flask application is involves handing SQLAlchemy objects and methods, its quite problematic (no?)
Read more >
Why don't I get code-completion in Flask/SQLAlchemy?
I'm facing the same problem using just SqlAlchemy without Flask. Python 3.10.7 SqlAlchemy 1.4.41. I read somewhere else, not sure now ...
Read more >
Python - Visual Studio Marketplace
Extension for Visual Studio Code - IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, ...
Read more >
SQLACODEGEN + VSCODE + Intellisense not working.
Jobmst is imported from a single module I've created called tidal.py. jobrow is an instance of Jobmst... But I can't select any of...
Read more >
VS Code Intellisense not working - Python Forum
The official dedicated python forum. ... Thread Modes. VS Code Intellisense not working ... from sqlalchemy.orm import sessionmaker
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found