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 When using Beanie with mypy strict typing, some typing issues make it impossible to pass the linter validation.
To Reproduce Here is an example of code:
import asyncio from typing import Optional from motor.motor_asyncio import AsyncIOMotorClient from pydantic import BaseModel from beanie import Document, init_beanie, operators class Category(BaseModel): name: str description: str class Product(Document): name: str description: Optional[str] = None price: float category: Category async def example() -> None: client = AsyncIOMotorClient("mongodb://user:pass@host:27017") await init_beanie(database=client["beanie_test"], document_models=[Product]) chocolate = Category( name="Chocolate", description="A preparation of roasted and ground cacao seeds.", ) tonybar = Product(name="Tony's", price=5.95, category=chocolate) await tonybar.insert() product = await Product.find_one(operators.LTE(Product.price, 10)) if __name__ == "__main__": asyncio.run(example())
Here is the output.
$ > mypy --stritct _local/test_mypy_1.py test_mypy_1.py:35: error: Call to untyped function "LTE" in typed context [no-untyped-call]
Expected behavior There should be no error
I believe this can be fixed by specifying the NoneType for the functions missing it.
If no objection, I can submit a Pull Request for the changes.
The text was updated successfully, but these errors were encountered:
Thank you for the catch! I'll add this case to the typing tests suite
Sorry, something went wrong.
Can I submit a PR for this
I would also like to see this implemented. It bugs me to have to use # type: ignore every time i use a operator
# type: ignore
BaseFindComparisonOperator
Successfully merging a pull request may close this issue.
Describe the bug
When using Beanie with mypy strict typing, some typing issues make it impossible to pass the linter validation.
To Reproduce
Here is an example of code:
Here is the output.
Expected behavior
There should be no error
I believe this can be fixed by specifying the NoneType for the functions missing it.
If no objection, I can submit a Pull Request for the changes.
The text was updated successfully, but these errors were encountered: