-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(framework): Fix flwr no args update check
#6939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,6 @@ class CommandKwargs(TypedDict): | |||||
| fg=typer.colors.BRIGHT_YELLOW, | ||||||
| bold=True, | ||||||
| ), | ||||||
| no_args_is_help=True, | ||||||
| context_settings={"help_option_names": ["-h", "--help"]}, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -151,6 +150,7 @@ def _is_json_output_requested(argv: list[str]) -> bool: | |||||
|
|
||||||
| @app.callback(invoke_without_command=True) | ||||||
| def main( | ||||||
| ctx: typer.Context, | ||||||
| version: bool = typer.Option( | ||||||
| None, | ||||||
| "-V", | ||||||
|
|
@@ -167,6 +167,10 @@ def main( | |||||
| typer.secho(f"Flower version: {package_version}", fg="blue") | ||||||
| raise typer.Exit() | ||||||
|
|
||||||
| if ctx.invoked_subcommand is None and len(sys.argv) == 1: | ||||||
|
||||||
| if ctx.invoked_subcommand is None and len(sys.argv) == 1: | |
| if ctx.invoked_subcommand is None and not ctx.args and not ctx.params: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detect no-arg invocations from Click context
Checking len(sys.argv) == 1 is not a reliable way to detect an empty flwr invocation when the CLI is called programmatically with explicit args (for example via Click/Typer test runners), because Click parses the provided arg list without updating process-wide sys.argv. In those calls, ctx.invoked_subcommand is None but this condition is false, so the callback skips the help/exit path and returns success with no output, which is a behavioral regression from the prior no_args_is_help=True behavior.
Useful? React with 👍 / 👎.
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new no-args handling prints help and then exits with code=2. Previously no_args_is_help=True would show help without treating it as a usage error; changing the exit code can be a breaking CLI behavior change for scripts. If the intent is still “show help on bare flwr”, consider exiting with code 0 (or otherwise matching the previous Click/Typer behavior).
| raise typer.Exit(code=2) | |
| raise typer.Exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a required
ctxparameter breaks direct invocations ofmainoutside Typer’s command runner, which now raisesTypeErrorbefore the callback logic runs. In this repo,framework/py/flwr/cli/cli_test.pycallsapp_module.main(version=False)directly to verify update-check behavior, so this change introduces an immediate regression for those call paths unlessctxis made optional or those callers are updated.Useful? React with 👍 / 👎.