Using Visual Studio 2022, Python 3.10, highlights most of PyMongo functions with red lines in strict syntax mode. Switching to the basic syntax hides a lot of issues.
In Visual Studio go to Tools > Options > Python > Analysys and select Strict in Type checking.
Make sure Python 3.10 (64-bit) is selected in the drop-down for the current Python environment, if more than one is available.
import pymongo def main(): mongo_client = pymongo.MongoClient("localhost:27017") db = mongo_client.get_database("test_db") col = db.get_collection("py_test") col.insert_one({"abc": 123}) if __name__ == "__main__": main()
Wait for IntelliSense to kick in (you may need to open just this folder with this file). You will see that all Mongo calls are highlighted with error squiggly lines.
If you hove over the errors, it will report errors like
Type of "get_collection" is partially unknown
Hovering over the highlighted method shows CodeOptions[Unknown], which seems to be what is triggering it. MongoClient error is slightly different, but of similar nature (document_class is Unknown).
I cannot attach a screenshot in this version of Jira (I could before). I will try to attach a screenshot in a comment.