Skip to content
Myr

Avoid use of filter() in format_commands, it breaks on Python3.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Oleksandr Shulgin · committed by Zachery Bir · parent 37233e2 · Browse files · 1 file+15 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−4 removed

  • other:+15 added−4 removed

1 file+15 added−4 removed

modified:click/core.py+15 added-4 removed
1022 unmodified lines
1023 def format_commands(self, ctx, formatter):1024 """Extra format methods for multi methods that adds all the commands1025 after the options.1026 """1027 commands = filter(lambda cmd: cmd[0] is not None or cmd[1].hidden,1028 [(c, self.get_command(ctx, c)) for c in self.list_commands(ctx)])1027 commands = []1028 for subcommand in self.list_commands(ctx):1029 cmd = self.get_command(ctx, subcommand)1030 # What is this, the tool lied about a command. Ignore it1031 if cmd is None:1032 continue1033 if cmd.hidden:1034 continue10351036 commands.append((subcommand, cmd))10371038 # allow for 3 times the default spacing1039 limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)10401032 rows = [(cmd[0], cmd[1].short_help or cmd[1].help and make_default_short_help(cmd[1].help, limit) or '')1033 for cmd in commands]1041 rows = []1042 for subcommand, cmd in commands:1043 help = cmd.short_help or cmd.help and make_default_short_help(cmd.help, limit)1044 rows.append((subcommand, help or ''))10451046 if rows:1047 with formatter.section('Commands'):1048 formatter.write_dl(rows)
777 unmodified lines