Skip to content
New issue

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

[BUG] Document constructor fails type check for instantiation with Mypy in strict mode #812

Closed
johnthagen opened this issue Dec 21, 2023 · 0 comments · Fixed by #813
Closed

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Dec 21, 2023

Describe the bug

Beanie is missing complete type annotations on some objects, such as Document, which cause Mypy to fail when used.

To Reproduce

The following code:

from beanie import Document

d = Document()

Throws a type check error when run with Mypy:

$ mypy main.py
main.py:3: error: Call to untyped function "Document" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

With the following Mypy configuration:

[tool.mypy]
strict = true

plugins = [
    "pydantic.mypy",
]

This config can be further simplified to

[tool.mypy]
disallow_untyped_calls = true

plugins = [
    "pydantic.mypy",
]

This seems to be because this line, the constructor is not fully typed, it is missing -> None:

https://github.com/roman-right/beanie/blob/5f03c6f6312fd0232505cc9bebf8ac1b22ca95ac/beanie/odm/documents.py#L189

Expected behavior

No Mypy type check errors when using Beanie, even with in strict mode.

Additional context

Reproduced on:

  • Python 3.11.6
  • Mypy 1.7.1
  • Beanie 1.23.6

Somewhat related to

@johnthagen johnthagen changed the title [BUG] Document type fails type check for instantiation with Mypy in strict mode [BUG] Document constructor fails type check for instantiation with Mypy in strict mode Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant