Visitar URL original
Create mypy plugin to handle common pitfalls · Issue #213 · ormar-orm/ormar · GitHub
Skip to content

Create mypy plugin to handle common pitfalls #213

Open

Description

@collerek

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.

Activity

  1. pmdevita commented on Feb 21, 2024

    @pmdevita
    Contributor

    I have experience writing mypy plugins and could do this, could you make a list of things the plugin would need to check for?

  2. collerek commented on Feb 26, 2024

    @collerek
    CollaboratorAuthor

    @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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions