Browse Source

pylightning: support functions with type annotations.

I tried annotating the plugin-millisatoshis.py plugin, and it failed like so:

	plugin-millisatoshis.py Killing plugin: "getmanifest" result is not an object: {"jsonrpc": "2.0", "id": 1, "error": "Error while processing getmanifest: ValueError(\'Function has keyword-only parameters or annotations, use getfullargspec() API which can support them\',)"}'

So, let's do that!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pr-2391
Rusty Russell 6 years ago
parent
commit
1982c73ebc
  1. 2
      contrib/pylightning/lightning/plugin.py

2
contrib/pylightning/lightning/plugin.py

@ -451,7 +451,7 @@ class Plugin(object):
# Handles out-of-order use of parameters like: # Handles out-of-order use of parameters like:
# def hello_obfus(arg1, arg2, plugin, thing3, request=None, thing5='at', thing6=21) # def hello_obfus(arg1, arg2, plugin, thing3, request=None, thing5='at', thing6=21)
argspec = inspect.getargspec(method.func) argspec = inspect.getfullargspec(method.func)
defaults = argspec.defaults defaults = argspec.defaults
num_defaults = len(defaults) if defaults else 0 num_defaults = len(defaults) if defaults else 0
start_kwargs_idx = len(argspec.args) - num_defaults start_kwargs_idx = len(argspec.args) - num_defaults

Loading…
Cancel
Save