mongo-types
mongo-types copied to clipboard
port argument of register_connection() is typed as str | None, but mongoengine expects int
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.