-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When the user defines keyword arguments as a variable and then passes it to a constructor, it can trip up mypy. For example:
kwargs = {'socketTimeoutMS': 100} kwargs['retryReads'] = False client = MongoClient(self.server.uri, **kwargs)
Gives the error:
Argument 2 to "MongoClient" has incompatible type "**Dict[str, int]"; expected "Type[Any]" [arg-type]
The deficiency is tracked in https://github.com/python/mypy/issues/8862.
We could look into offering a TypeDict as a workaround with optional values, so that the user could use code like:
kwargs: MongoClientOptions = {'socketTimeoutMS': 100} kwargs['retryReads'] = False client = MongoClient(self.server.uri, **kwargs)