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

PyCharm: No autocomplete when creating new instances #115

Open
8 tasks done
adlmtl opened this issue Sep 28, 2021 · 15 comments
Open
8 tasks done

PyCharm: No autocomplete when creating new instances #115

adlmtl opened this issue Sep 28, 2021 · 15 comments
Labels
question Further information is requested

Comments

@adlmtl
Copy link

adlmtl commented Sep 28, 2021

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the SQLModel documentation, with the integrated search.
  • I already searched in Google "How to X in SQLModel" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to SQLModel but to Pydantic.
  • I already checked if it is not related to SQLModel but to SQLAlchemy.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from datetime import datetime

from sqlmodel import Field, SQLModel
from typing import Optional


class MyModel(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    dev_email: str = Field(index=True)
    account_id: str = Field(index=True)
    other_id: Optional[str] = None
    failed: Optional[bool] = False
    created: datetime = Field(sa_column_kwargs={'default': datetime.utcnow})
    updated: datetime = Field(sa_column_kwargs={'default': datetime.utcnow, 'onupdate': datetime.utcnow})

Description

  • Create Model
  • Create new instance of model
  • I expected to see autocompletion for model attributes as shown in the features section of docs

Operating System

macOS

Operating System Details

No response

SQLModel Version

0.0.4

Python Version

3.8

Additional Context

No autocompletion in PyCharm when creating new instance. (only when fetching an instance from db)

image

@adlmtl adlmtl added the question Further information is requested label Sep 28, 2021
@woprandi
Copy link

I think it's a PyCharm issue https://youtrack.jetbrains.com/issue/PY-30187

@5cat
Copy link

5cat commented Nov 26, 2021

The same issue exist in Pydantic and they made a plugin for it in PyCharm. I tried it in the hopes that it might fix this issue but sadly it only worked on pydantic models.

@white54503
Copy link

white54503 commented Jan 3, 2022

I found a fix here: koxudaxi/pydantic-pycharm-plugin#344. Relevant provided you've installed the Pydantic plugin.

tldr: Add the following lines to your pyproject.yaml.

[tool.pydantic-pycharm-plugin]
ignore-init-method-arguments = true

I had to restart Pycharm to get it working.

@thomhickey
Copy link

@white54503 solution didn't work for me, I still only get autocomplete on instantiated objects, not on the sqlmodel table class itself for example when writing queries:

image

@tapicer
Copy link

tapicer commented Sep 6, 2022

This is still an issue with PyCharm 2022.2.1, any workaround? Pydantic's plugin doesn't help with the query's columns autocompletion.

@ronalddas
Copy link

Installing the pydantic plugin worked for me, am running Pycharm 2022.2.1 Build #PY-222.3739.56

@tapicer
Copy link

tapicer commented Sep 8, 2022

Installing the pydantic plugin worked for me, am running Pycharm 2022.2.1 Build #PY-222.3739.56

It does work for me when creating new instances, but it doesn't when making queries with SQLModel. Does that work for you?

@ronalddas
Copy link

Installing the pydantic plugin worked for me, am running Pycharm 2022.2.1 Build #PY-222.3739.56

It does work for me when creating new instances, but it doesn't when making queries with SQLModel. Does that work for you?

Yeah only works for creating new instances, I also tried doing the toml file config, still doesn't work as expected l

@lironesamoun
Copy link

No news about this issue ?

@alex-linx
Copy link

I'm also having this issue in pycharm 2023.1.
I get autocomplete on instances of SQLModel, but can't get autocomplete on fields of the class.
It does work in VSCode.
Any news on this?

@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.

If this resolves your issue, feel free to explore concise solutions through my book https://pythonalliance.gumroad.com/l/ayuze where you can uncover efficient one line fixes.

@pvlbzn
Copy link

pvlbzn commented Jan 24, 2024

Still an issue with PyCharm 2023.3.2 (Professional Edition).

@linpan
Copy link

linpan commented May 6, 2024

Still an issue with PyCharm 2024.1.1 (Professional Edition).

@Meowzz95
Copy link

Still an issue with PyCharm 2024.2.3 (Professional Edition).

@kssion
Copy link

kssion commented Feb 25, 2025

Still an issue with PyCharm 2024.3.3 (Professional Edition).

Image Image

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

No branches or pull requests