Skip to content

BeanieUserDatabase type check fails with Pyright #12

Open
@barraponto

Description

@barraponto

Describe the bug

Pyright complains when BeanieUserDatabase gets a subclass of both BeanieBaseUser and beanie.Document.

Argument of type "type[User]" cannot be assigned to parameter "user_model" of type "type[UP_BEANIE@BeanieUserDatabase]" in function "__init__"

To Reproduce

from beanie import Document
from fastapi_users.db import BeanieBaseUser
from fastapi_users_db_beanie import BeanieUserDatabase


class User(BeanieBaseUser, Document):
    pass


async def get_user_db():
    return BeanieUserDatabase(User)

Expected behavior

No type errors.

Configuration

  • Python version : 3.11.6
  • FastAPI Users version : 12.1.2
  • FastAPI Users DB Beanie version : 3.0.0

Additional context

Particularly, I see BeanieBaseUserDocument defined as literally a subclass of both BeanieBaseUser and beanie.Document. But defining a TypeVar bond to BeanieBaseUserDocument does not accept another subclass of the same classes :/

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