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

port argument of register_connection() is typed as str | None, but mongoengine expects int #70

Open
edward-petersen-cynn opened this issue Aug 1, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@edward-petersen-cynn
Copy link

mypy reports that the port argument for the register_connection() function needs to be either a string or None:

Argument "port" to "register_connection" has incompatible type "int"; expected "str | None"  [arg-type]

Which is what the mongoengine-stubs/connection.pyi file dictates. But when I replace it with a string representation of the port number, mongoengine reports the port must be an integer.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/mongoengine/connection.py", line 348, in _create_connection
    return mongo_client_class(**connection_settings)
  File "/usr/local/lib/python3.10/site-packages/pymongo/mongo_client.py", line 715, in __init__
    raise TypeError("port must be an instance of int")
TypeError: port must be an instance of int

According to pymongo on github, the type check on the port has been there for 11 years, so I think this is just an oversight.

@sbdchd sbdchd added the bug Something isn't working label Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants