I'm wondering what's the best approach to deal with unknown types of functions/methods associated with other modules. Note that I'm using strict
mode
For example, I have the following:
rooms: List[str] = list(mongo_client.devices.distinct("room"))
mongo_client
is just an instance of a MongoClient
imported from pymongo
. VSCode screams that it doesn't know the type of the distinct
method:
Type of "distinct" is partially unknown
Type of "distinct" is "(key: Unknown, filter: Unknown = None, session: Unknown = None, **kwargs: Unknown) -> Unknown"PylancereportUnknownMemberType
Argument type is unknown
Argument corresponds to parameter "iterable" in function "__init__"PylancereportUnknownArgumentType
What I can do:
- Add
reportUnknownMemberType
topyrightconfig.json
; however, while this removes the previous warning, it's also going to disable warnings that I probably really want - Add
# type: ignore
on the line with that distinct call; I usually hate having flying ignore-comments like this and I don't think it "fixes" anything - Create a stub file myself
What would you do? Should I not use strict
mode? Most of the project was written with the strict mode activated to make sure I'm not missing anything. Is these some cast
trick I can do?
Thanks!