original_docstring: 
      Creates a function with signature <func_signature> that will call <func_impl> with its arguments when called.
      Arguments are passed as keyword-arguments when it is possible (so all the time, except for var-positional or
      positional-only arguments that get passed as *args. Note that pos-only does not yet exist in python but this case
      is already covered because it is supported by `Signature` objects).
  
      `func_signature` can be provided:
  
       - as a string containing the name and signature without 'def' keyword, such as `'foo(a, b: int, *args, **kwargs)'`.
        In which case the name in the string will be used for the `__name__` and `__qualname__` of the created function
        by default
       - as a `Signature` object, for example created using `signature(f)` or handcrafted. In this case the `__name__`
        and `__qualname__` of the created function will be copied from `func_impl` by default.
  
      All the other metadata of the created function are defined as follows:
  
       - default `__name__` attribute (see above) can be overriden by providing a non-None `func_name`
       - default `__qualname__` attribute (see above) can be overridden by providing a non-None `qualname`
       - `__annotations__` attribute is created to match the annotations in the signature.
       - `__doc__` attribute is copied from `func_impl.__doc__` except if overridden using `doc`
       - `__module__` attribute is copied from `func_impl.__module__` except if overridden using `module_name`
  
      Finally two new attributes are optionally created
  
       - `__source__` attribute: set if `add_source` is `True` (default), this attribute contains the source code of the
       generated function
       - `__func_impl__` attribute: set if `add_impl` is `True` (default), this attribute contains a pointer to
       `func_impl`
  
      :param func_signature: either a string without 'def' such as "foo(a, b: int, *args, **kwargs)" or "(a, b: int)",
          or a `Signature` object, for example from the output of `inspect.signature` or from the `funcsigs.signature`
          backport. Note that these objects can be created manually too. If the signature is provided as a string and
          contains a non-empty name, this name will be used instead of the one of the decorated function.
      :param func_impl: the function that will be called when the generated function is executed. Its signature should
          be compliant with (=more generic than) `func_signature`
      :param inject_as_first_arg: if `True`, the created function will be injected as the first positional argument of
          `func_impl`. This can be handy in case the implementation is shared between several facades and needs
          to know from which context it was called. Default=`False`
      :param func_name: provide a non-`None` value to override the created function `__name__` and `__qualname__`. If this
          is `None` (default), the `__name__` will default to the one of `func_impl` if `func_signature` is a `Signature`,
          or to the name defined in `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param add_source: a boolean indicating if a '__source__' annotation should be added to the generated function
          (default: True)
      :param add_impl: a boolean indicating if a '__func_impl__' annotation should be added to the generated function
          (default: True)
      :param doc: a string representing the docstring that will be used to set the __doc__ attribute on the generated
          function. If None (default), the doc of func_impl will be used.
      :param qualname: a string representing the qualified name to be used. If None (default), the `__qualname__` will
          default to the one of `func_impl` if `func_signature` is a `Signature`, or to the name defined in
          `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param module_name: the name of the module to be set on the function (under __module__ ). If None (default),
          `func_impl.__module__` will be used.
      :param attrs: other keyword attributes that should be set on the function
      :return:
      
docstring: Creates a function with signature  that will call  with its arguments when called.
  Arguments are passed as keyword-arguments when it is possible (so all the time, except for var-positional or
  positional-only arguments that get passed as *args. Note that pos-only does not yet exist in python but this case
  is already covered because it is supported by `Signature` objects).
  
  `func_signature` can be provided.
  
  as a string containing the name and signature without 'def' keyword, such as `'foo(a, b: int, *args, **kwargs)'`.
  
  All the other metadata of the created function are defined as follows.
  
  
  
  Finally two new attributes are optionally created
  
  
docstring_tokens: Creates a function with signature that will call with its arguments when called . Arguments are passed as keyword - arguments when it is possible ( so all the time except for var - positional or positional - only arguments that get passed as * args . Note that pos - only does not yet exist in python but this case is already covered because it is supported by ` Signature ` objects ) . ` func_signature ` can be provided . as a string containing the name and signature without ' def ' keyword such as ` ' foo ( a b : int * args ** kwargs ) ' ` . All the other metadata of the created function are defined as follows . Finally two new attributes are optionally created
code: def create_function(func_signature,             # type: Union[str, Signature]
                      func_impl,                  # type: Callable[[Any], Any]
                      func_name=None,             # type: str
                      inject_as_first_arg=False,  # type: bool
                      add_source=True,            # type: bool
                      add_impl=True,              # type: bool
                      doc=None,                   # type: str
                      qualname=None,              # type: str
                      module_name=None,           # type: str
                      **attrs):
      """
      Creates a function with signature <func_signature> that will call <func_impl> with its arguments when called.
      Arguments are passed as keyword-arguments when it is possible (so all the time, except for var-positional or
      positional-only arguments that get passed as *args. Note that pos-only does not yet exist in python but this case
      is already covered because it is supported by `Signature` objects).
  
      `func_signature` can be provided:
  
       - as a string containing the name and signature without 'def' keyword, such as `'foo(a, b: int, *args, **kwargs)'`.
        In which case the name in the string will be used for the `__name__` and `__qualname__` of the created function
        by default
       - as a `Signature` object, for example created using `signature(f)` or handcrafted. In this case the `__name__`
        and `__qualname__` of the created function will be copied from `func_impl` by default.
  
      All the other metadata of the created function are defined as follows:
  
       - default `__name__` attribute (see above) can be overriden by providing a non-None `func_name`
       - default `__qualname__` attribute (see above) can be overridden by providing a non-None `qualname`
       - `__annotations__` attribute is created to match the annotations in the signature.
       - `__doc__` attribute is copied from `func_impl.__doc__` except if overridden using `doc`
       - `__module__` attribute is copied from `func_impl.__module__` except if overridden using `module_name`
  
      Finally two new attributes are optionally created
  
       - `__source__` attribute: set if `add_source` is `True` (default), this attribute contains the source code of the
       generated function
       - `__func_impl__` attribute: set if `add_impl` is `True` (default), this attribute contains a pointer to
       `func_impl`
  
      :param func_signature: either a string without 'def' such as "foo(a, b: int, *args, **kwargs)" or "(a, b: int)",
          or a `Signature` object, for example from the output of `inspect.signature` or from the `funcsigs.signature`
          backport. Note that these objects can be created manually too. If the signature is provided as a string and
          contains a non-empty name, this name will be used instead of the one of the decorated function.
      :param func_impl: the function that will be called when the generated function is executed. Its signature should
          be compliant with (=more generic than) `func_signature`
      :param inject_as_first_arg: if `True`, the created function will be injected as the first positional argument of
          `func_impl`. This can be handy in case the implementation is shared between several facades and needs
          to know from which context it was called. Default=`False`
      :param func_name: provide a non-`None` value to override the created function `__name__` and `__qualname__`. If this
          is `None` (default), the `__name__` will default to the one of `func_impl` if `func_signature` is a `Signature`,
          or to the name defined in `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param add_source: a boolean indicating if a '__source__' annotation should be added to the generated function
          (default: True)
      :param add_impl: a boolean indicating if a '__func_impl__' annotation should be added to the generated function
          (default: True)
      :param doc: a string representing the docstring that will be used to set the __doc__ attribute on the generated
          function. If None (default), the doc of func_impl will be used.
      :param qualname: a string representing the qualified name to be used. If None (default), the `__qualname__` will
          default to the one of `func_impl` if `func_signature` is a `Signature`, or to the name defined in
          `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param module_name: the name of the module to be set on the function (under __module__ ). If None (default),
          `func_impl.__module__` will be used.
      :param attrs: other keyword attributes that should be set on the function
      :return:
      """
      # grab context from the caller frame
      try:
          attrs.pop('_with_sig_')
          # called from `@with_signature`
          frame = _get_callerframe(offset=1)
      except KeyError:
          frame = _get_callerframe()
      evaldict, _ = extract_module_and_evaldict(frame)
  
      # name defaults
      user_provided_name = True
      if func_name is None:
          func_name = func_impl.__name__
          user_provided_name = False
  
      # qname default
      user_provided_qname = True
      if qualname is None:
          qualname = getattr(func_impl, '__qualname__', None)
          user_provided_qname = False
  
      # doc default
      if doc is None:
          doc = getattr(func_impl, '__doc__', None)
  
      # module name default
      if module_name is None:
          module_name = func_impl.__module__
  
      # input signature handling
      if isinstance(func_signature, str):
          # transform the string into a Signature and make sure the string contains ":"
          func_name_from_str, func_signature, func_signature_str = get_signature_from_string(func_signature, evaldict)
  
          # if not explicitly overridden using `func_name`, the name in the string takes over
          if func_name_from_str is not None:
              if not user_provided_name:
                  func_name = func_name_from_str
              if not user_provided_qname:
                  qualname = func_name
  
          # fix the signature if needed
          if func_name_from_str is None:
              func_signature_str = func_name + func_signature_str
  
      elif isinstance(func_signature, Signature):
          # create the signature string
          func_signature_str = get_signature_string(func_name, func_signature, evaldict)
  
      else:
          raise TypeError("Invalid type for `func_signature`: %s" % type(func_signature))
  
      # extract all information needed from the `Signature`
      params_to_kw_assignment_mode = get_signature_params(func_signature)
      params_names = list(params_to_kw_assignment_mode.keys())
  
      # Note: in decorator the annotations were extracted using getattr(func_impl, '__annotations__') instead.
      # This seems equivalent but more general (provided by the signature, not the function), but to check
      annotations, defaults, kwonlydefaults = get_signature_details(func_signature)
  
      # create the body of the function to compile
      # The generated function body should dispatch its received arguments to the inner function.
      # For this we will pass as much as possible the arguments as keywords.
      # However if there are varpositional arguments we cannot
      assignments = [("%s=%s" % (k, k)) if is_kw else k for k, is_kw in params_to_kw_assignment_mode.items()]
      params_str = ', '.join(assignments)
      if inject_as_first_arg:
          params_str = "%s, %s" % (func_name, params_str)
  
      if _is_generator_func(func_impl):
          if sys.version_info >= (3, 3):
              body = "def %s\n    yield from _func_impl_(%s)\n" % (func_signature_str, params_str)
          else:
              from makefun._main_legacy_py import get_legacy_py_generator_body_template
              body = get_legacy_py_generator_body_template() % (func_signature_str, params_str)
      else:
          body = "def %s\n    return _func_impl_(%s)\n" % (func_signature_str, params_str)
  
      if iscoroutinefunction(func_impl):
          body = ("async " + body).replace('return', 'return await')
  
      # create the function by compiling code, mapping the `_func_impl_` symbol to `func_impl`
      protect_eval_dict(evaldict, func_name, params_names)
      evaldict['_func_impl_'] = func_impl
      f = _make(func_name, params_names, body, evaldict)
  
      # add the source annotation if needed
      if add_source:
          attrs['__source__'] = body
  
      # add the handler if needed
      if add_impl:
          attrs['__func_impl__'] = func_impl
  
      # update the signature
      _update_fields(f, name=func_name, qualname=qualname, doc=doc, annotations=annotations,
                     defaults=tuple(defaults), kwonlydefaults=kwonlydefaults,
                     module=module_name, **attrs)
  
      return f
code_tokens: def create_function ( func_signature , func_impl , func_name = None , inject_as_first_arg = False , add_source = True , add_impl = True , doc = None , qualname = None , module_name = None , ** attrs ) : try : attrs . pop ( '_with_sig_' ) frame = _get_callerframe ( offset = 1 ) except KeyError : frame = _get_callerframe ( ) evaldict , _ = extract_module_and_evaldict ( frame ) user_provided_name = True if func_name is None : func_name = func_impl . __name__ user_provided_name = False user_provided_qname = True if qualname is None : qualname = getattr ( func_impl , '__qualname__' , None ) user_provided_qname = False if doc is None : doc = getattr ( func_impl , '__doc__' , None ) if module_name is None : module_name = func_impl . __module__ if isinstance ( func_signature , str ) : func_name_from_str , func_signature , func_signature_str = get_signature_from_string ( func_signature , evaldict ) if func_name_from_str is not None : if not user_provided_name : func_name = func_name_from_str if not user_provided_qname : qualname = func_name if func_name_from_str is None : func_signature_str = func_name + func_signature_str elif isinstance ( func_signature , Signature ) : func_signature_str = get_signature_string ( func_name , func_signature , evaldict ) else : raise TypeError ( "Invalid type for `func_signature`: %s" % type ( func_signature ) ) params_to_kw_assignment_mode = get_signature_params ( func_signature ) params_names = list ( params_to_kw_assignment_mode . keys ( ) ) annotations , defaults , kwonlydefaults = get_signature_details ( func_signature ) assignments = [ ( "%s=%s" % ( k , k ) ) if is_kw else k for k , is_kw in params_to_kw_assignment_mode . items ( ) ] params_str = ', ' . join ( assignments ) if inject_as_first_arg : params_str = "%s, %s" % ( func_name , params_str ) if _is_generator_func ( func_impl ) : if sys . version_info >= ( 3 , 3 ) : body = "def %s\n    yield from _func_impl_(%s)\n" % ( func_signature_str , params_str ) else : from makefun . _main_legacy_py import get_legacy_py_generator_body_template body = get_legacy_py_generator_body_template ( ) % ( func_signature_str , params_str ) else : body = "def %s\n    return _func_impl_(%s)\n" % ( func_signature_str , params_str ) if iscoroutinefunction ( func_impl ) : body = ( "async " + body ) . replace ( 'return' , 'return await' ) protect_eval_dict ( evaldict , func_name , params_names ) evaldict [ '_func_impl_' ] = func_impl f = _make ( func_name , params_names , body , evaldict ) if add_source : attrs [ '__source__' ] = body if add_impl : attrs [ '__func_impl__' ] = func_impl _update_fields ( f , name = func_name , qualname = qualname , doc = doc , annotations = annotations , defaults = tuple ( defaults ) , kwonlydefaults = kwonlydefaults , module = module_name , ** attrs ) return f
short_docstring: Creates a function with signature <func_signature> that will call <func_impl> with its arguments when called.
short_docstring_tokens: Creates a function with signature <func_signature > that will call <func_impl > with its arguments when called .
comment: # type: Union[str, Signature]$SEP$# type: Callable[[Any], Any]$SEP$# type: str$SEP$# type: bool$SEP$# type: bool$SEP$# type: bool$SEP$# type: str$SEP$# type: str$SEP$# type: str$SEP$"""
      Creates a function with signature <func_signature> that will call <func_impl> with its arguments when called.
      Arguments are passed as keyword-arguments when it is possible (so all the time, except for var-positional or
      positional-only arguments that get passed as *args. Note that pos-only does not yet exist in python but this case
      is already covered because it is supported by `Signature` objects).
  
      `func_signature` can be provided:
  
       - as a string containing the name and signature without 'def' keyword, such as `'foo(a, b: int, *args, **kwargs)'`.
        In which case the name in the string will be used for the `__name__` and `__qualname__` of the created function
        by default
       - as a `Signature` object, for example created using `signature(f)` or handcrafted. In this case the `__name__`
        and `__qualname__` of the created function will be copied from `func_impl` by default.
  
      All the other metadata of the created function are defined as follows:
  
       - default `__name__` attribute (see above) can be overriden by providing a non-None `func_name`
       - default `__qualname__` attribute (see above) can be overridden by providing a non-None `qualname`
       - `__annotations__` attribute is created to match the annotations in the signature.
       - `__doc__` attribute is copied from `func_impl.__doc__` except if overridden using `doc`
       - `__module__` attribute is copied from `func_impl.__module__` except if overridden using `module_name`
  
      Finally two new attributes are optionally created
  
       - `__source__` attribute: set if `add_source` is `True` (default), this attribute contains the source code of the
       generated function
       - `__func_impl__` attribute: set if `add_impl` is `True` (default), this attribute contains a pointer to
       `func_impl`
  
      :param func_signature: either a string without 'def' such as "foo(a, b: int, *args, **kwargs)" or "(a, b: int)",
          or a `Signature` object, for example from the output of `inspect.signature` or from the `funcsigs.signature`
          backport. Note that these objects can be created manually too. If the signature is provided as a string and
          contains a non-empty name, this name will be used instead of the one of the decorated function.
      :param func_impl: the function that will be called when the generated function is executed. Its signature should
          be compliant with (=more generic than) `func_signature`
      :param inject_as_first_arg: if `True`, the created function will be injected as the first positional argument of
          `func_impl`. This can be handy in case the implementation is shared between several facades and needs
          to know from which context it was called. Default=`False`
      :param func_name: provide a non-`None` value to override the created function `__name__` and `__qualname__`. If this
          is `None` (default), the `__name__` will default to the one of `func_impl` if `func_signature` is a `Signature`,
          or to the name defined in `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param add_source: a boolean indicating if a '__source__' annotation should be added to the generated function
          (default: True)
      :param add_impl: a boolean indicating if a '__func_impl__' annotation should be added to the generated function
          (default: True)
      :param doc: a string representing the docstring that will be used to set the __doc__ attribute on the generated
          function. If None (default), the doc of func_impl will be used.
      :param qualname: a string representing the qualified name to be used. If None (default), the `__qualname__` will
          default to the one of `func_impl` if `func_signature` is a `Signature`, or to the name defined in
          `func_signature` if `func_signature` is a `str` and contains a non-empty name.
      :param module_name: the name of the module to be set on the function (under __module__ ). If None (default),
          `func_impl.__module__` will be used.
      :param attrs: other keyword attributes that should be set on the function
      :return:
      """$SEP$# grab context from the caller frame$SEP$# called from `@with_signature`$SEP$# name defaults$SEP$# qname default$SEP$# doc default$SEP$# module name default$SEP$# input signature handling$SEP$# transform the string into a Signature and make sure the string contains ":"$SEP$# if not explicitly overridden using `func_name`, the name in the string takes over$SEP$# fix the signature if needed$SEP$# create the signature string$SEP$# extract all information needed from the `Signature`$SEP$# Note: in decorator the annotations were extracted using getattr(func_impl, '__annotations__') instead.$SEP$# This seems equivalent but more general (provided by the signature, not the function), but to check$SEP$# create the body of the function to compile$SEP$# The generated function body should dispatch its received arguments to the inner function.$SEP$# For this we will pass as much as possible the arguments as keywords.$SEP$# However if there are varpositional arguments we cannot$SEP$# create the function by compiling code, mapping the `_func_impl_` symbol to `func_impl`$SEP$# add the source annotation if needed$SEP$# add the handler if needed$SEP$# update the signature