def validate_is_mapping(option, value):
    """Validate the type of method arguments that expect a document."""
    if not isinstance(value, abc.Mapping):
        raise TypeError("%s must be an instance of dict, bson.son.SON, or "
                        "any other type that inherits from "
                        "collections.Mapping" % (option,))
Validate the type of method arguments that expect a document.
stackoverflow/venv/lib/python3.6/site-packages/pymongo/common.py