Skip to content

Conversation

daneah
Copy link
Collaborator

@daneah daneah commented Apr 15, 2025

Typer allows passing a default_factory to options and arguments, which is a callable that will be used at runtime to determine the default value. Typer sets the option's default on the Click command object to the supplied factory value.

The Textual application created by Trogon crashes when this is used, because it tries to convert the str representation of the callable function for display when it should be converting the result of calling that function instead.

I don't think I fully understand why this crash occurs, since it appears that Trogon properly handles a default Click application when an option's default is e.g. a lambda. Perhaps Typer is missing something in its translation of default_factory to Click's default, and I'm open to filing an issue/opening a PR on their end if it appears that's the case, but I'd need help in better understanding it!

Typer allows passing a `default_factory` to options and arguments, which
is a callable that will be used at runtime to determine the default
value. The Textual application created by Trogon crashes when this is
used, because it tries to convert the str representation of the callable
function for display when it should be converting the result of calling
that function instead. This change ensures dynamic default values do not
crash the application, and has the effect of setting the default value
appropriately in the TUI.
@daneah daneah requested a review from darrenburns April 15, 2025 14:18
@gaby
Copy link

gaby commented Jul 25, 2025

@daneah Any plans to merge this? Progress has staled on trogon.

@daneah
Copy link
Collaborator Author

daneah commented Jul 25, 2025

@gaby even if I merge this (I can't without a review from another maintainer), I don't have release privileges unfortunately. I think that other folks with those privileges have other life things going on.

@gaby
Copy link

gaby commented Jul 25, 2025

@daneah Ohhh, that explains it. Thanks for the info. Do you know who we can ping about that?

@daneah
Copy link
Collaborator Author

daneah commented Jul 25, 2025

@gaby The list of org people is where to for this kind of thing, typically.

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