ormar
ormar copied to clipboard
Create mypy plugin to handle common pitfalls
Since a lot of things in ormar
are generated dynamically mypy
does not play well with some of them.
That's the idea behind custom plugin enhancing how mypy handles ormar, similar to the one used by pydantic.
I have experience writing mypy plugins and could do this, could you make a list of things the plugin would need to check for?
@pmdevita Great to hear that! :)
The most crucial things are:
- reverse relation fields that are added to models in runtime are not detected
- ormar is changing the type of the Field despite what you put in in the type hint in pydantic, so if you have so if you do
field_name: int = ormar.String()
in reality field_name will have type string despite your type hint. It's more complicated for relations where those are changed with unions (cause you can set relation with Model, dictionary or just primary key value), the field type is set on pydantic model so might be extracted from there