Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@commands.HttpMethodFactory(None)
def func():
pass
def test_call_as_decorator_with_args(self):
method_factory = commands.HttpMethodFactory(None)
@method_factory(None)
def func():
pass
assert isinstance(func, commands.RequestDefinitionBuilder)
# 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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__
# 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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__
def extend(self, uri=None, args=()):
factory = HttpMethodFactory(
method=self.method, request_definition_builder_factory=self._extend
)
if callable(uri):
return factory(self.uri.template, args)(uri)
else:
uri = self.uri.template if uri is None else uri
return factory(uri, args)
)
# 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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__
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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__
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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__
# 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
get = HttpMethodFactory("GET").__call__
head = HttpMethodFactory("HEAD").__call__
put = HttpMethodFactory("PUT").__call__
post = HttpMethodFactory("POST").__call__
patch = HttpMethodFactory("PATCH").__call__
delete = HttpMethodFactory("DELETE").__call__