code: def assert_is_valid_key(key):
      """
      Raise KeyError if a given config key violates any requirements.
  
      The requirements are the following and can be individually deactivated
      in ``sacred.SETTINGS.CONFIG_KEYS``:
        * ENFORCE_MONGO_COMPATIBLE (default: True):
          make sure the keys don't contain a '.' or start with a '$'
        * ENFORCE_JSONPICKLE_COMPATIBLE (default: True):
          make sure the keys do not contain any reserved jsonpickle tags
          This is very important. Only deactivate if you know what you are doing.
        * ENFORCE_STRING (default: False):
          make sure all keys are string.
        * ENFORCE_VALID_PYTHON_IDENTIFIER (default: False):
          make sure all keys are valid python identifiers.
  
      Parameters
      ----------
      key:
        The key that should be checked
  
      Raises
      ------
      KeyError:
        if the key violates any requirements
  
      """
      if SETTINGS.CONFIG.ENFORCE_KEYS_MONGO_COMPATIBLE and (
          isinstance(key, str) and ("." in key or key[0] == "$")
      ):
          raise KeyError(
              'Invalid key "{}". Config-keys cannot '
              'contain "." or start with "$"'.format(key)
          )
  
      if (
          SETTINGS.CONFIG.ENFORCE_KEYS_JSONPICKLE_COMPATIBLE
          and isinstance(key, str)
          and (
              key in jsonpickle.tags.RESERVED
              or key.startswith("json://")
          )
      ):
          raise KeyError(
              'Invalid key "{}". Config-keys cannot be one of the'
              "reserved jsonpickle tags: {}".format(
                  key, jsonpickle.tags.RESERVED
              )
          )
  
      if SETTINGS.CONFIG.ENFORCE_STRING_KEYS and (
          not isinstance(key, str)
      ):
          raise KeyError(
              'Invalid key "{}". Config-keys have to be strings, '
              "but was {}".format(key, type(key))
          )
  
      if SETTINGS.CONFIG.ENFORCE_VALID_PYTHON_IDENTIFIER_KEYS and (
          isinstance(key, str) and not PYTHON_IDENTIFIER.match(key)
      ):
          raise KeyError(
              'Key "{}" is not a valid python identifier'.format(key)
          )
  
      if SETTINGS.CONFIG.ENFORCE_KEYS_NO_EQUALS and (
          isinstance(key, str) and "=" in key
      ):
          raise KeyError(
              'Invalid key "{}". Config keys may not contain an'
              'equals sign ("=").'.format("=")
          )
  
file_path: sacred/sacred/config/utils.py
imports: import jsonpickle.tags
  from sacred import SETTINGS
  import sacred.optional
  from sacred.config.custom_containers import DogmaticDict, DogmaticList
  from sacred.utils import PYTHON_IDENTIFIER
label_desc: Use image node_id 1 for calling a global function with example usage: assert_is_valid_key(key) without return types