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

Can not auto complete for Flask-SQLAlchemy #1372

Closed
archcst opened this issue Jul 19, 2019 · 2 comments
Closed

Can not auto complete for Flask-SQLAlchemy #1372

archcst opened this issue Jul 19, 2019 · 2 comments

Comments

@archcst
Copy link

archcst commented Jul 19, 2019

Other packages can be auto complete(like render_templates):
fdda30d00eb4f371a098c012209c81aa5deb5304

But SQLAlchemy can't(when I type id = db.Column):
799114b606e995561c1d003f5eb771aa2ce84e86

Here's my setup in ~/.spacemacs.d/init.el

(defun dotspacemacs/user-config ()
  ;; python configurations:
  (require 'pyvenv)
  (add-to-list 'company-backends 'company-anaconda)
  (add-to-list 'company-backends 'company-jedi)
  (add-to-list 'company-backends 'company-web)
  (add-hook 'python-mode-hook 'anaconda-mode)
  (add-hook 'python-mode-hook (lambda () (pyvenv-activate (concat (projectile-project-root) "/venv"))))
  (setq web-mode-engines-alist
        '(("django"    . "\\.html\\'")))
  (setq tab-width 4)
  (setq py-indent-offset 4)
  (setq python-spacemacs-indent-guess nil)
  (setq python-indent-guess-indent-offset nil)
  (setq org-confirm-babel-evaluate nil)
)

And here's the pipfile:

Package          Version
---------------- -------
alembic          1.0.11
argh             0.26.2
Click            7.0
Flask            1.1.0
Flask-CKEditor   0.4.3
Flask-Migrate    2.5.2
Flask-SQLAlchemy 2.4.0
Flask-WTF        0.14.2
itsdangerous     1.1.0
jedi             0.14.0
Jinja2           2.10.1
Mako             1.0.13
MarkupSafe       1.1.1
parso            0.5.0
pathtools        0.1.2
pip              19.1.1
python-dateutil  2.8.0
python-dotenv    0.10.3
python-editor    1.0.4
PyYAML           5.1.1
setuptools       39.0.1
six              1.12.0
SQLAlchemy       1.3.5
watchdog         0.9.0
Werkzeug         0.15.4
WTForms          2.2.1

Emacs version:

- OS: darwin
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 5df46b200)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm

company-backends:

Value:
((company-anaconda . #1=(:with company-yasnippet))
 (company-semantic company-dabbrev-code company-gtags company-etags company-keywords . #1#)
 (company-files . #1#)
 (company-dabbrev . #1#))
Original value was 
(company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-dabbrev)
Local in buffer app.py; global value is 
(company-web company-jedi company-anaconda company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
             (company-dabbrev-code company-gtags company-etags company-keywords)
             company-oddmuse company-dabbrev)
@davidhalter
Copy link
Owner

They are using a lot of dynamic code to make this happen: https://github.com/pallets/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L724

So this is pretty much something that won't be coming to Jedi anytime soon. So #626 might help you eventually, but this is not going to happen very soon. I'm also pretty sure that this is not going to be part of Jedi but part of an external project, if somebody ever writes one.

My suggestion for you is: Write stubs and use them. Jedi understands them and you are going to be fine. Everything else likely won't happen. You probably could also do a pull request on the flask-sqlalchemy project to add stubs.

@auroraostrovica
Copy link

auroraostrovica commented Dec 20, 2023

In my experience, the most effective solution for flask sqlalchemy autocomplete is by installing flask-sqlalchemy-stubs package, a method I've found to be particularly insightful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants