Support for pydantic-like Models?
See original GitHub issueHi, I’m using your plugin for quite some time and it’s awesome - thanks for your work! 😃
I’m developing ormar - a mini async orm with fastapi in mind, that uses pydantic for validation (https://github.com/collerek/ormar)
I’m subclassing the pydanic.BaseModel
as my ormar.Model
and hacking around with pydantic internals to make it work.
(You can ignore Meta class below, the field definition is like in pydantic but I use my custom fields classes as type hints - id and name in example).
It does kind of work, but in example above it shows Base clases of my fields, and I would like to display user=User(id: Integer, name: String)
, or even better -> user=User(id:int, name:str)
I’m already playing with __annotations__
, pydantic fields shape
, type_
and a lot of internals, so I would like to adjust my models/ fields to play well with your plugin.
But for that I need information from where do you grab the information to display in code completion, hints etc.
I’m also exposing QuerySet operations like User.objects.create(**kwargs)
or User.objects.update(**kwargs)
that as kwargs should accept only pydantic/ormar fields -> can you somehow register a custom function to be picked up by your plugin, or make it work in other way (so display hints like in __init__()
).
I tried looking into your code but saw a huge number of jetbeans dependencies and I don’t even know kotlin 😄
So would be really grateful for info how I can adjust my project to be more in line with your plugin, as I find it super useful.
Thanks in advance and sorry for the long text.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Ok, so I redesigned the models definition in v0.4.0 and if you provide type hints all plays well with your plugin:
So now I have only this question if I can somehow add other methods that should have exactly the same hints and arguments as the
__init__()
?you need to write code for prototyping The best is you run the plugin with a debugger.
I’m thinking of an approach. I implemented a feature to treat create_model https://github.com/koxudaxi/pydantic-pycharm-plugin/issues/169 If your method is similar to
create_model
, we can go to the next step.Did you tell me about the method? Does the method have a pydantic model? the plugin needs to lookup the model. Also, What does the method return? the class of model? or instantiated model class?