We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug There is a type error calling init_beanie():
init_beanie()
Argument "document_models" to "init_beanie" has incompatible type "list[type[Document]]"; expected "list[type[<nothing>] | type[View] | str] | None" [arg-type]
To Reproduce
from beanie import Document, init_beanie from motor.motor_asyncio import AsyncIOMotorClient class MyModel(Document): foo: str async def example() -> None: client = AsyncIOMotorClient("mongodb://user:pass@host:27017") await init_beanie(database=client.db_name, document_models=[MyModel]) # <- raises the type error
Expected behavior No type error.
Additional context
The text was updated successfully, but these errors were encountered:
Hi @markedwards , Could you please tell what are you using? MyPy or pyright, and respective version. Thank you
Sorry, something went wrong.
@roman-right -- mypy 1.5.1.
I believe you need to have strict=True set in order to reveal the error.
strict=True
My guess is this can be resolved with this signature:
document_models: Optional[Sequence[Union[Type["DocType"], Type["View"], str]]]
or even simpler:
document_models: Optional[Sequence[Union[Type[Document], Type[View], str]]]
I think you are right, that change should be enough
Successfully merging a pull request may close this issue.
Describe the bug
There is a type error calling
init_beanie()
:To Reproduce
Expected behavior
No type error.
Additional context
The text was updated successfully, but these errors were encountered: