Skip to content

馃悰 Use the first app or function defined in the file in the typer command - #1952

Open
lenamonj wants to merge 1 commit into
fastapi:masterfrom
lenamonj:fix-typer-command-app-order
Open

馃悰 Use the first app or function defined in the file in the typer command#1952
lenamonj wants to merge 1 commit into
fastapi:masterfrom
lenamonj:fix-typer-command-app-order

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 4, 2026

Copy link
Copy Markdown

The typer command picks "any Typer app" and "any function" by iterating a set of module names, so which one runs depends on the process hash seed. A file that defines zeta = typer.Typer() and then alpha = typer.Typer() runs alpha on five of eight PYTHONHASHSEED values and zeta on the other three. The docs promise "the first Typer app available in the file, with any name" and "the first function in the file".

This iterates the module's names in definition order instead, and the any-name function fallback accepts only functions defined in that file, so an imported callable such as pathlib.Path can no longer be picked.

Two new tests run each asset under eight hash seeds; both fail on master and pass with the change. scripts/test.sh (1382 passed) and scripts/lint.sh are clean.

@lenamonj
lenamonj force-pushed the fix-typer-command-app-order branch from 30793ab to 52fc347 Compare September 4, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants