コード例 #1
0
 def __call__(self, func):
     spec = utils.get_arg_spec(func)
     arg_handler = types.ArgumentAnnotationHandlerBuilder(func, spec.args)
     builder = RequestDefinitionBuilder(
         self._method, URIDefinitionBuilder(self._uri), arg_handler,
         decorators.MethodAnnotationHandlerBuilder())
     arg_handler.add_annotations_from_spec(spec)
     if spec.return_annotation is not None:
         builder = decorators.returns(spec.return_annotation)(builder)
     functools.update_wrapper(builder, func)
     return builder
コード例 #2
0
 def __call__(self, func):
     spec = utils.get_arg_spec(func)
     arg_handler = types.ArgumentAnnotationHandlerBuilder(func, spec.args)
     method_handler = decorators.MethodAnnotationHandlerBuilder()
     builder = RequestDefinitionBuilder(self._method,
                                        URIDefinitionBuilder(self._uri),
                                        arg_handler, method_handler)
     if spec.args:
         # Ignore `self` instance reference
         spec.annotations.pop(spec.args[0], None)
     arg_handler.set_annotations(spec.annotations)
     if spec.return_annotation is not None:
         builder = decorators.returns(spec.return_annotation)(builder)
     functools.update_wrapper(builder, func)
     return builder
コード例 #3
0
    def __call__(self, func):
        spec = utils.get_arg_spec(func)
        arg_handler = arguments.ArgumentAnnotationHandlerBuilder(
            func, spec.args)
        builder = RequestDefinitionBuilder(
            self._method,
            URIDefinitionBuilder(self._uri),
            arg_handler,
            decorators.MethodAnnotationHandlerBuilder(),
        )

        # Need to add the annotations after constructing the request
        # definition builder so it has a chance to attach its listener.
        arg_handler.set_annotations(spec.annotations)

        # Use return value type hint as expected return type
        if spec.return_annotation is not None:
            builder = returns.schema(spec.return_annotation)(builder)
        functools.update_wrapper(builder, func)
        builder = self._add_args(builder)
        return builder
コード例 #4
0
ファイル: test_decorators.py プロジェクト: vault-the/uplink
def method_handler_builder():
    return decorators.MethodAnnotationHandlerBuilder()