code: def option_hook(self, function):
          
          sig = Signature(function)
          if "options" not in sig.arguments:
              raise KeyError("option_hook functions must have an argument called"
                             " 'options', but got {}".format(sig.arguments))
          self.option_hooks.append(function)
          return function
docs: Decorator for adding an option hook function.
  
          An option hook is a function that is called right before a run
          is created. It receives (and potentially modifies) the options
          dictionary. That is, the dictionary of commandline options used for
          this run.
  
          .. note::
              The decorated function MUST have an argument called options.
  
              The options also contain ``'COMMAND'`` and ``'UPDATE'`` entries,
              but changing them has no effect. Only modification on
              flags (entries starting with ``'--'``) are considered.