Skip to content

🐛 Ensure that typer.launch forwards correctly when launching a file#1708

Merged
tiangolo merged 4 commits intofastapi:masterfrom
svlandeg:fix/launch
Apr 22, 2026
Merged

🐛 Ensure that typer.launch forwards correctly when launching a file#1708
tiangolo merged 4 commits intofastapi:masterfrom
svlandeg:fix/launch

Conversation

@svlandeg
Copy link
Copy Markdown
Member

The current code in main.py didn't forward the locate and wait arguments to click. When launching a file and setting locate=True, Click would open a file manager instead of launching the file directly. The Typer docstring indicate the same behaviour is targeted.

From the added unit test in this PR, we see this isn't actually happening on master. When forwarding the arguments correctly, the behaviour is as expected.

Running this test on Windows only because it doesn't feel necessary to mock this behaviour for the various OS's.

@svlandeg svlandeg added the bug Something isn't working label Apr 20, 2026
Comment thread tests/test_launch.py
typer.launch("not a url")

launch_mock.assert_called_once_with("not a url")
launch_mock.assert_called_once_with("not a url", wait=False, locate=False)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original test would fail with this PR and needs to be adjusted. False is the default value for both of these parameters so it's correct that those are now getting forwarded when calling typer.launch.

@svlandeg svlandeg marked this pull request as ready for review April 20, 2026 08:53
Copy link
Copy Markdown
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you! 🙌

This will be available in Typer 0.24.2, released in the next few hours. 🚀

@tiangolo tiangolo merged commit 31b468b into fastapi:master Apr 22, 2026
22 checks passed
@svlandeg svlandeg deleted the fix/launch branch April 22, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants