Skip to content

Commit

Permalink
Add missing type hints convert callable names to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Garulf committed Jan 25, 2024
1 parent 5536ab5 commit 97dfc8f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyflowlauncher/event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


from typing import Any, Callable
from typing import Any, Callable, Iterable


class EventHandler:
Expand All @@ -9,10 +9,13 @@ def __init__(self):
self._methods = {}
self._handlers = {}

def add_method(self, method, *, name=None):
self._methods[name or method.__name__] = method
def _get_callable_name(self, method: Callable[..., Any]):
return getattr(method, '__name__', method.__class__.__name__).lower()

def add_methods(self, methods):
def add_method(self, method: Callable[..., Any], *, name=None):
self._methods[name or self._get_callable_name(method)] = method

def add_methods(self, methods: Iterable[Callable[..., Any]]):
for method in methods:
self.add_method(method)

Expand Down

0 comments on commit 97dfc8f

Please sign in to comment.