Switch back to events.name defaulting to None, use typing.cast to fix linting

error
This commit is contained in:
jesopo 2019-05-18 21:14:28 +01:00
parent 3b9efe769a
commit 7671dd2086

View file

@ -46,7 +46,7 @@ class EventCallback(object):
return item or self.docstring.items.get(name, default) return item or self.docstring.items.get(name, default)
class EventHook(object): class EventHook(object):
def __init__(self, log: Logging.Log, name: str = "", def __init__(self, log: Logging.Log, name: str = None,
parent: "EventHook" = None): parent: "EventHook" = None):
self.log = log self.log = log
self.name = name self.name = name
@ -85,7 +85,8 @@ class EventHook(object):
return self._hook(function, context, priority, replay, kwargs) return self._hook(function, context, priority, replay, kwargs)
def _hook(self, function: CALLBACK_TYPE, context: typing.Optional[str], def _hook(self, function: CALLBACK_TYPE, context: typing.Optional[str],
priority: int, replay: bool, kwargs: dict) -> EventCallback: priority: int, replay: bool, kwargs: dict) -> EventCallback:
callback = EventCallback(self.name, function, priority, kwargs, event_name = typing.cast(str, self.name)
callback = EventCallback(event_name, function, priority, kwargs,
context) context)
if context == None: if context == None: