Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_validate_positionals():
validate_args(lambda x: None, 1)
def test_validate_object_method():
class FooClass:
def foo(self, one, two):
return "bar"
validate_args(FooClass().foo, "one", "two")
def test_validate_keywords():
validate_args(lambda **kwargs: None, foo="bar")
def test_validate_positionals_not_passed():
with pytest.raises(InvalidParamsError):
validate_args(lambda x: None, foo="bar")
def test_validate_no_arguments():
validate_args(lambda: None)
def call(method: Method, *args: Any, **kwargs: Any) -> Any:
"""
Validates arguments and then calls the method.
Args:
method: The method to call.
*args, **kwargs: Arguments to the method.
Returns:
The "result" part of the JSON-RPC response (the return value from the method).
"""
return validate_args(method, *args, **kwargs)(*args, **kwargs)