Skip to content

Commit

Permalink
Remove redundant if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed Jun 5, 2021
1 parent d77e737 commit 3e914a3
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lightbulb/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,11 @@ def remove_command(self, name: str) -> typing.Optional[str]:

self.commands.remove(command)

if command is not None:
keys_to_remove = [command.name, *command._aliases]
keys_to_remove.remove(name)
for key in keys_to_remove:
self._commands.pop(key)
_LOGGER.debug("command removed: %s", command.name)
keys_to_remove = [command.name, *command._aliases]
keys_to_remove.remove(name)
for key in keys_to_remove:
self._commands.pop(key)
_LOGGER.debug("command removed: %s", command.name)

return command.name

Expand All @@ -506,17 +505,16 @@ def remove_plugin(self, name: str) -> typing.Optional[str]:

plugin.plugin_remove()

if plugin is not None:
for k in plugin._commands.keys():
self.remove_command(k)
for k in plugin._commands.keys():
self.remove_command(k)

for event_type, listeners in plugin.listeners.items():
for listener in listeners:
callback = listener.__get__(plugin, type(plugin))
self.unsubscribe(listener.event_type, callback)
_LOGGER.debug("listener removed: %s (%s)", callback.__name__, listener.event_type.__name__)
for event_type, listeners in plugin.listeners.items():
for listener in listeners:
callback = listener.__get__(plugin, type(plugin))
self.unsubscribe(listener.event_type, callback)
_LOGGER.debug("listener removed: %s (%s)", callback.__name__, listener.event_type.__name__)

_LOGGER.debug("plugin removed: %s", plugin.name)
_LOGGER.debug("plugin removed: %s", plugin.name)

return plugin.name

Expand Down

0 comments on commit 3e914a3

Please sign in to comment.