Skip to content
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

fix: Do not override the command order of a custom group's list_commands() #33

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions sphinxcontrib/typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,20 @@ def get_function(function: t.Union[str, t.Callable[..., t.Any]]):


def _filter_commands(ctx: click.Context, cmd_filter: t.Optional[t.List[str]] = None):
return sorted(
[
cmd
for name, cmd in getattr(
ctx.command,
"commands",
{
name: ctx.command.get_command(ctx, name)
for name in getattr(ctx.command, "list_commands", lambda _: [])(ctx)
or cmd_filter
or []
},
).items()
if not cmd_filter or name in cmd_filter
],
key=lambda item: item.name,
)
return [
cmd
for name, cmd in getattr(
ctx.command,
"commands",
{
name: ctx.command.get_command(ctx, name)
for name in getattr(ctx.command, "list_commands", lambda _: [])(ctx)
or cmd_filter
or []
},
).items()
if not cmd_filter or name in cmd_filter
]


class RenderTarget(str, Enum):
Expand Down
Loading