question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keyword-only arguments in pipeline function signature break the compilation

See original GitHub issue

/kind bug

What steps did you take and what happened: Pass a pipeline function that has keyword-only arguments, e.g. def pipeline(*, keyword_only_argument: str).

Compiler rises:

TypeError: missing a required argument: 'keyword_only_argument'

What did you expect to happen: Pipeline working just fine, just like for non-keyword-only arguments, e.g. def pipeline(casual_argument: str).

Additional information: Origins in compiler.py due to using FullArgsSpec.args, which doesn’t contain keyword-only arguments:

argspec = inspect.getfullargspec(pipeline_func)
(...)
for arg_name in argspec.args:
  args_list.append(...)

with dsl.Pipeline(pipeline_name) as dsl_pipeline:
  pipeline_func(*args_list)

Environment:

Irrelevant.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ckadnercommented, Sep 25, 2020

So the FullArgSpec does contain the kwonlyargs, which we could make use of here.

class FullArgSpec(NamedTuple):
    args: List[str]
    varargs: Optional[str]
    varkw: Optional[str]
    defaults: Optional[Tuple[Any, ...]]
    kwonlyargs: List[str]
    kwonlydefaults: Optional[Dict[str, Any]]
    annotations: Dict[str, Any]

But is that really a useful thing to do? Why would you define a dsl.Pipeline function with varargs (*) followed by kwonlyargs? Should your pipeline function not have to know about the arguments by name in order to do something useful with them?

0reactions
stale[bot]commented, Jun 4, 2021

This issue has been automatically closed because it has not had recent activity. Please comment “/reopen” to reopen it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keyword-only arguments in pipeline function signature break ...
Create a pipeline function with keyword-only argument(s). Pass it to compile . def some_pipeline(*, keyword_only_argument: str): pass ...
Read more >
python - What is the safe way of using keyword-only arguments?
Advantages: It's less error-prone. When having positional arguments in a function call, changing a signature can break things. With keyword-only ...
Read more >
Functions - Julia Documentation
Keyword argument default values are evaluated only when necessary (when a corresponding keyword argument is not passed), and in left-to-right order. Therefore ...
Read more >
Keyword-only Arguments in Python - Medium
A keyword argument is an argument preceded by an identifier (named arguments). Notice that the value here is passed in a function call...
Read more >
Robot Framework User Guide
As the first example of using free named arguments, let's take a look at Run Process keyword in the Process library. It has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found