Skip to content
Browse files

[Bugfix] Processing @alg decorator support input help string (#40207)

(cherry picked from commit 0b28107)
  • Loading branch information
rldhont authored and nyalldawson committed Dec 21, 2020
1 parent da85fb6 commit d9d5f20b2a21719053a00af44c4242daf910c54b
Showing with 33 additions and 0 deletions.
  1. +3 −0 python/processing/
  2. +30 −0 tests/src/python/
@@ -194,6 +194,7 @@ def _create_param(self, type, output=False, **kwargs):
kwargs['description'] = kwargs.pop("label", "")
kwargs['defaultValue'] = kwargs.pop("default", None)
advanced = kwargs.pop("advanced", False)
help_str = kwargs.pop("help", "")
if output:
@@ -208,6 +209,8 @@ def _create_param(self, type, output=False, **kwargs):
parm = make_func(**kwargs)
if advanced:
parm.setFlags(parm.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
if not output:
return parm
except KeyError as ex:
raise NotImplementedError("{} not supported".format(str(type)))
@@ -48,6 +48,20 @@ def testalg(instance, parameters, context, feedback, inputs):

def define_new_input_help(newid=1):
@alg(name=ARGNAME.format(newid),"Test func"), group="unittest","Test label"))
@alg.input(type=alg.SOURCE, name="INPUT", label="Input layer", help="The input layer as source")
@alg.input(type=alg.DISTANCE, name="DISTANCE", label="Distance", default=30, help="The distance to split the input layer")
@alg.input(type=alg.SINK, name="SINK", label="Output layer", help="The output layer as sink")
@alg.output(type=str, name="DISTANCE_OUT", label="Distance out")
def testalg(instance, parameters, context, feedback, inputs):
Given a distance will split a line layer into segments of the distance

def define_new_doc_string(newid=1):
@alg(name=ARGNAME.format(newid),"Test func"), group="unittest","Test label"))
@@ -151,6 +165,22 @@ def test_has_help_from_docstring(self):
current = alg.instances.pop()
self.assertEqual("Test doc string text", current.shortHelpString())

def test_has_input_help(self):
current = alg.instances.pop()
defs = current.parameterDefinitions()
self.assertEqual(3, len(defs))
inputs = [
("INPUT", "The input layer as source"),
("DISTANCE", "The distance to split the input layer"),
("SINK", "The output layer as sink"),
for count, data in enumerate(inputs):
parmdef = defs[count]

class TestAlg(unittest.TestCase):

0 comments on commit d9d5f20

Please sign in to comment.
You can’t perform that action at this time.