Skip to content

Commit

Permalink
fix: always print plugins sorted by name
Browse files Browse the repository at this point in the history
`tutor plugins list` used to print plugins in random oredr. To be honest
this has always bothered me.
  • Loading branch information
regisb committed Nov 8, 2021
1 parent d9d08ad commit 485f47f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".

## Unreleased

- [Improvement] Make `tutor plugins list` print plugins sorted by name.
- [Improvement] Ignore Python plugins which cannot be loaded.

## v12.1.6 (2021-11-02)
Expand Down
5 changes: 4 additions & 1 deletion tutor/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,14 @@ def iter_installed(cls) -> Iterator[BasePlugin]:
prevent too many re-computations, which happens a lot.
"""
installed_plugin_names = set()
plugins = []
for PluginClass in cls.PLUGIN_CLASSES:
for plugin in PluginClass.iter_installed():
if plugin.name not in installed_plugin_names:
installed_plugin_names.add(plugin.name)
yield plugin
plugins.append(plugin)
plugins = sorted(plugins, key=lambda plugin: plugin.name)
yield from plugins

def iter_enabled(self) -> Iterator[BasePlugin]:
for plugin in self.iter_installed():
Expand Down

0 comments on commit 485f47f

Please sign in to comment.