koxudaxi / pydantic-pycharm-plugin

PyCharm plugin for pydantic. This plugin provides autocompletion, inspection, type-checking, inserting unfilled argument, and more.
https://koxudaxi.github.io/pydantic-pycharm-plugin/
MIT License
451 stars 16 forks source link

Add SQLModel support for pycharm #418

Open masreplay opened 2 years ago

masreplay commented 2 years ago

Can you please add support for SQLModel class which is inherited from Pydantic

Funding

Fund with Polar

koxudaxi commented 2 years ago

@masreplay Thank you for creating the issue. OK, I will check it.

javivdm commented 2 years ago

This would be amazing!

fozt commented 2 years ago

Sqlmodel columns are inherited from sqlaclhemy and can be accessed before init is called, unlike pydantic models. When the plugin is applied, pycharm stops prompting. Also, pycharm does not suggest methods of sqlalchemy columns (in_, op, ...). Please add support for this

from sqlmodel import Field, SQLModel

class User(SQLModel, table=True):
    name: str = Field(primary_key=True)
    email: str

# first problem
print(User.name)
print(User.email)

# second problem
print(type(User.name.op), type(User.name.in_))