Skip to content

Commit

Permalink
fix(plugin): make remove_command actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharp-Eyes committed Jan 3, 2023
1 parent fd9e199 commit 8239f72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sail/impl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ def add_command(self, command: command_trait.Command[typing.Any, typing.Any]) ->

self._commands[command.name] = command

def remove_command(self, command: command_trait.Command[typing.Any, typing.Any]) -> None:
if command.name in self._commands:
raise RuntimeError(
f"Plugin {self.name!r} does not have a command named {command.name!r}."
)
def remove_command(self, command: command_trait.Command[typing.Any, typing.Any] | str) -> None:
name = command.name if isinstance(command, command_trait.Command) else command
if name not in self._commands:
raise RuntimeError(f"Plugin {self.name!r} does not have a command named {name!r}.")

self._commands.pop(name)

def command(
self,
Expand Down
1 change: 1 addition & 0 deletions sail/traits/command_trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __call__(self, *__args: typing.Any, **kwargs: typing.Any) -> typing.Any:
...


@typing.runtime_checkable
class Command(typing.Protocol[P, T_co]):
__slots__: typing.Sequence[str] = ("name", "description", "aliases", "callback")

Expand Down

0 comments on commit 8239f72

Please sign in to comment.