From 603bd564305519ee30f15aab787e9595a899ae96 Mon Sep 17 00:00:00 2001 From: Romain Cledat Date: Tue, 19 Nov 2024 01:04:49 -0800 Subject: [PATCH] Again --- metaflow/cli.py | 3 +++ metaflow/cmd/develop/stub_generator.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metaflow/cli.py b/metaflow/cli.py index 83f340967c6..f19fa605584 100644 --- a/metaflow/cli.py +++ b/metaflow/cli.py @@ -88,6 +88,9 @@ def echo_always(line, **kwargs): click.secho(ERASE_TO_EOL, **kwargs) +echo = None + + def logger(body="", system_msg=False, head="", bad=False, timestamp=True, nl=True): if timestamp: if timestamp is True: diff --git a/metaflow/cmd/develop/stub_generator.py b/metaflow/cmd/develop/stub_generator.py index b5686d50c36..2093f4d34d4 100644 --- a/metaflow/cmd/develop/stub_generator.py +++ b/metaflow/cmd/develop/stub_generator.py @@ -1238,22 +1238,23 @@ def exploit_default(default_value: Any) -> Optional[str]: buff.write(indentation + deco + "\n") buff.write(indentation + "def " + name + "(") kw_only_param = False + has_var_args = False for i, (par_name, parameter) in enumerate(my_sign.parameters.items()): annotation = self._exploit_annotation(parameter.annotation) default = exploit_default(parameter.default) - if kw_only_param and parameter.kind not in ( - inspect.Parameter.KEYWORD_ONLY, - inspect.Parameter.VAR_KEYWORD, - ): + if kw_only_param and parameter.kind != inspect.Parameter.KEYWORD_ONLY: raise RuntimeError( "In function '%s': cannot have a positional parameter after a " "keyword only parameter" % name ) + has_var_args |= parameter.kind == inspect.Parameter.VAR_KEYWORD + if ( parameter.kind == inspect.Parameter.KEYWORD_ONLY and not kw_only_param + and not has_var_args ): kw_only_param = True buff.write("*, ")