18799: Mark self parameters as POSITIONAL_OR_KEYWORD
authorBrett Smith <brett.smith@curii.com>
Fri, 14 Apr 2023 14:06:23 +0000 (10:06 -0400)
committerBrett Smith <brett.smith@curii.com>
Fri, 14 Apr 2023 14:06:23 +0000 (10:06 -0400)
On Python 3.7, if you mark a parameter POSITIONAL_ONLY, it will generate
a signature that uses the positional-only `/` syntax, *even though*
Python 3.7 cannot parse that syntax (it was added in Python 3.8, PEP 570).

POSITIONAL_OR_KEYWORD avoids that problem, and is probably more accurate
anyway.

Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith@curii.com>

sdk/python/discovery2pydoc.py

index 57ae3161330a42ef7629917c450801a4cff94c42..ad7606145a199b95738f0045cdf08fedbb3f1fe3 100755 (executable)
@@ -200,7 +200,7 @@ class Method:
 
     def signature(self) -> inspect.Signature:
         parameters = [
-            inspect.Parameter('self', inspect.Parameter.POSITIONAL_ONLY),
+            inspect.Parameter('self', inspect.Parameter.POSITIONAL_OR_KEYWORD),
             *self._required_params,
             *self._optional_params,
         ]