Python 3.9 is now generally available.

google.appengine.datastore.datastore_stub_util.CheckReference

Check this key.

request_trusted If the request is trusted.
request_app_id The application ID of the app making the request.
key entity_pb2.Reference
require_id_or_name Boolean indicating if we should enforce the presence of an id or name in the last element of the key's path.

apiproxy_errors.ApplicationError if the key is invalid