Skip to content

Commit

Permalink
fix: fixed typing in EventFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Apr 22, 2021
1 parent 006e5ab commit f39dfa1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions aw_watcher_afk/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@
import threading
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from typing import Dict, Any

logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)


class EventFactory(metaclass=ABCMeta):
def __init__(self):
def __init__(self) -> None:
self.new_event = threading.Event()
self._reset_data()

@abstractmethod
def _reset_data(self):
raise NotImplementedError
def _reset_data(self) -> None:
self.event_data: Dict[str, Any] = {}

def next_event(self):
def next_event(self) -> dict:
"""Returns an event and prepares the internal state so that it can start to build a new event"""
self.new_event.clear()
data = self.event_data
# self.logger.debug(f"Event: {data}")
self._reset_data()
return data

def has_new_event(self):
def has_new_event(self) -> bool:
return self.new_event.is_set()


Expand Down

0 comments on commit f39dfa1

Please sign in to comment.