BeanieODM/beanie

[BUG] mypy does not raise error when trying to access a non-existing attribute from a beanie Document.

marwan-alloreview opened this issue · 1 comments

Describe the bug
mypy does not raise error when trying to access a non-existing attribute from a beanie Document. It works fine with a pydantic model.

To Reproduce

from pydantic import BaseModel
from beanie import Document


class TestPydantic(BaseModel):
    foo: str


class TestBeanie(Document):
    foo: str


test_pydantic = TestPydantic(foo="test")
test_beanie = TestBeanie(foo="test")

print(test_pydantic.bar)  # This is detected as an error by mypy
print(test_beanie.bar)  # This is not

Expected behavior
missing attributes in Documents should be detected by mypy the same way as with pydantic's BaseModels

Additional context

beanie = "1.25.0"
mypy = "1.6.1"

Sorry, this is likely a duplicate of #671. I am closing the issue.