Skip to content

Commit d0e37fb

Browse files
pyln-client: Remove category, description and long description from methods
Removed deprecated fields from pyln methods. Changelog-Removed: pyln-client: Removed `category`, `description`, and `long descriptions` from pyln-client.
1 parent 2f64283 commit d0e37fb

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

contrib/pyln-client/pyln/client/plugin.py

+8-32
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ class Method(object):
4848
"""
4949
def __init__(self, name: str, func: Callable[..., JSONType],
5050
mtype: MethodType = MethodType.RPCMETHOD,
51-
deprecated: Union[bool, List[str]] = None,
52-
description: str = None):
51+
deprecated: Union[bool, List[str]] = None):
5352
self.name = name
5453
self.func = func
5554
self.mtype = mtype
5655
self.background = False
5756
self.deprecated = deprecated
58-
self.description = description
5957
self.before: List[str] = []
6058
self.after: List[str] = []
6159

@@ -83,9 +81,6 @@ def get_usage(self):
8381
else:
8482
args.append("[%s]" % arg)
8583

86-
if self.description is not None:
87-
args.append("\n%s" % self.description)
88-
8984
return " ".join(args)
9085

9186

@@ -354,8 +349,7 @@ def convert_featurebits(
354349

355350
def add_method(self, name: str, func: Callable[..., Any],
356351
background: bool = False,
357-
deprecated: Optional[Union[bool, List[str]]] = None,
358-
description: str = None) -> None:
352+
deprecated: Optional[Union[bool, List[str]]] = None) -> None:
359353
"""Add a plugin method to the dispatch table.
360354
361355
The function will be expected at call time (see `_dispatch`)
@@ -392,7 +386,7 @@ def add_method(self, name: str, func: Callable[..., Any],
392386
)
393387

394388
# Register the function with the name
395-
method = Method(name, func, MethodType.RPCMETHOD, deprecated, description)
389+
method = Method(name, func, MethodType.RPCMETHOD, deprecated)
396390
method.background = background
397391
self.methods[name] = method
398392

@@ -506,36 +500,25 @@ def get_option(self, name: str) -> Optional[Any]:
506500
else:
507501
return self.options[name].default
508502

509-
def async_method(self, method_name: str, category: Optional[str] = None,
510-
desc: Optional[str] = None,
511-
long_desc: Optional[str] = None,
503+
def async_method(self, method_name: str,
512504
deprecated: Optional[Union[bool, List[str]]] = None) -> NoneDecoratorType:
513505
"""Decorator to add an async plugin method to the dispatch table.
514506
515507
Internally uses add_method.
516508
"""
517509
def decorator(f: Callable[..., None]) -> Callable[..., None]:
518-
for attr, attr_name in [(category, "Category"), (desc, "Description"), (long_desc, "Long description")]:
519-
if attr is not None:
520-
self.log("{} is deprecated but defined in method {}; it will be ignored by Core Lightning".format(attr_name, method_name), level="warn")
521510
self.add_method(method_name, f, background=True, deprecated=deprecated)
522511
return f
523512
return decorator
524513

525-
def method(self, method_name: str, category: Optional[str] = None,
526-
desc: Optional[str] = None,
527-
long_desc: Optional[str] = None,
528-
deprecated: Union[bool, List[str]] = None,
529-
description: str = None) -> JsonDecoratorType:
514+
def method(self, method_name: str,
515+
deprecated: Union[bool, List[str]] = None) -> JsonDecoratorType:
530516
"""Decorator to add a plugin method to the dispatch table.
531517
532518
Internally uses add_method.
533519
"""
534520
def decorator(f: Callable[..., JSONType]) -> Callable[..., JSONType]:
535-
for attr, attr_name in [(category, "Category"), (desc, "Description"), (long_desc, "Long description")]:
536-
if attr is not None:
537-
self.log("{} is deprecated but defined in method {}; it will be ignored by Core Lightning".format(attr_name, method_name), level="warn")
538-
self.add_method(method_name, f, background=False, deprecated=deprecated, description=f.__doc__)
521+
self.add_method(method_name, f, background=False, deprecated=deprecated)
539522
return f
540523
return decorator
541524

@@ -948,16 +931,9 @@ def _getmanifest(self, **kwargs) -> JSONType:
948931
doc = "Undocumented RPC method from a plugin."
949932
doc = re.sub('\n+', ' ', doc)
950933

951-
# For compatibility with lightningd prior to 24.08, we must
952-
# provide a description. Ignored by 24.08 onwards,
953-
description = method.description
954-
if description is None:
955-
description = ""
956-
957934
methods.append({
958935
'name': method.name,
959-
'usage': method.get_usage(),
960-
'description': description,
936+
'usage': method.get_usage()
961937
})
962938

963939
manifest = {

contrib/pyln-client/tests/test_plugin.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,15 @@ def some_method(some_arg: str = None):
448448
manifest = p._getmanifest()
449449
usage = p.get_usage()
450450

451+
print("MANIFEST")
452+
print(manifest)
453+
print("USAGE")
454+
print(usage)
455+
assert manifest['rpcmethods'][0] is False
456+
451457
assert manifest['rpcmethods'][0]['name'] == 'some_method'
452458
assert "some_arg" in manifest['rpcmethods'][0]['usage']
453459
assert "some description" in manifest['rpcmethods'][0]['usage']
454460
assert "some_method" in usage
455461
assert "some_arg" in usage
456-
assert "some description" in usage
462+
assert "some added description" in usage

0 commit comments

Comments
 (0)