Skip to content

Pyright complains about parameters for UUID field #938

Description

@kirberich

Describe the bug
When using UUID fields and pyright for type checking, pyright complains that the uuid field's parameters don't exist:
Screenshot 2022-11-18 at 12 00 04

From having a quick look, I think this is caused by the fact that the fields inherit from their contained types, but unlike all the other types, uuid.UUID has an __init__ function, and the type checker cannot see that BaseField is added as a base during runtime

I think the solution might be as simple as adding an init to the uuid field, but I'm not sure if this breaks somewhere else:

    def __init__(self, *, uuid_format: str = "hex", **kwargs: Any):
        return super().__init__(**kwargs)

To Reproduce
Steps to reproduce the behavior:

  1. Use vscode with pyright and basic type checking enabled
  2. Create a model with a uuid field, pass along any ormar field parameter, like default
  3. Pyright complains

Here's a simple reconstruction of the problem: https://gist.github.com/kirberich/7879b577d391f424951056af7cb91757

Expected behavior
Pyright should see the expected field parameters for ormar fields, not uuid.UUID

Versions (please complete the following information):

  • Database backend used: postgres 13
  • Python version: 3.10.7
  • ormar version: 0.12.0
  • pydantic version: 1.10.2
  • if applicable fastapi version: 0.85.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions