Skip to content

Commit

Permalink
Modernize super() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed May 13, 2022
1 parent 3e064cf commit a60ab4f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/watchdog/observers/api.py
Expand Up @@ -101,7 +101,7 @@ class EventEmitter(BaseThread):
"""

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
BaseThread.__init__(self)
super().__init__()
self._event_queue = event_queue
self._watch = watch
self._timeout = timeout
Expand Down Expand Up @@ -164,7 +164,7 @@ class EventDispatcher(BaseThread):
"""Event inserted into the queue to signal a requested stop."""

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseThread.__init__(self)
super().__init__()
self._event_queue = EventQueue()
self._timeout = timeout

Expand Down Expand Up @@ -211,7 +211,7 @@ class BaseObserver(EventDispatcher):
"""Base observer."""

def __init__(self, emitter_class, timeout=DEFAULT_OBSERVER_TIMEOUT):
EventDispatcher.__init__(self, timeout)
super().__init__(timeout)
self._emitter_class = emitter_class
self._lock = threading.RLock()
self._watches = set()
Expand Down
5 changes: 2 additions & 3 deletions src/watchdog/observers/fsevents.py
Expand Up @@ -78,7 +78,7 @@ class FSEventsEmitter(EventEmitter):
"""

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT, suppress_history=False):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)
self._fs_view = set()
self.suppress_history = suppress_history
self._start_time = 0.0
Expand Down Expand Up @@ -337,8 +337,7 @@ def _encode_path(self, path):
class FSEventsObserver(BaseObserver):

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseObserver.__init__(self, emitter_class=FSEventsEmitter,
timeout=timeout)
super().__init__(emitter_class=FSEventsEmitter, timeout=timeout)

def schedule(self, event_handler, path, recursive=False):
# Fix for issue #26: Trace/BPT error when given a unicode path
Expand Down
4 changes: 2 additions & 2 deletions src/watchdog/observers/fsevents2.py
Expand Up @@ -183,7 +183,7 @@ class FSEventsEmitter(EventEmitter):
"""

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)
self._fsevents = FSEventsQueue(watch.path)
self._fsevents.start()

Expand Down Expand Up @@ -243,4 +243,4 @@ def queue_events(self, timeout):

class FSEventsObserver2(BaseObserver):
def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseObserver.__init__(self, emitter_class=FSEventsEmitter, timeout=timeout)
super().__init__(emitter_class=FSEventsEmitter, timeout=timeout)
11 changes: 4 additions & 7 deletions src/watchdog/observers/inotify.py
Expand Up @@ -109,7 +109,7 @@ class InotifyEmitter(EventEmitter):
"""

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)
self._lock = threading.Lock()
self._inotify = None

Expand Down Expand Up @@ -208,7 +208,7 @@ class InotifyFullEmitter(InotifyEmitter):
``float``
"""
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
InotifyEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)

def queue_events(self, timeout, events=True):
InotifyEmitter.queue_events(self, timeout, full_events=events)
Expand All @@ -221,8 +221,5 @@ class InotifyObserver(BaseObserver):
"""

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT, generate_full_events=False):
if (generate_full_events):
BaseObserver.__init__(self, emitter_class=InotifyFullEmitter, timeout=timeout)
else:
BaseObserver.__init__(self, emitter_class=InotifyEmitter,
timeout=timeout)
cls = InotifyFullEmitter if generate_full_events else InotifyEmitter
super().__init__(emitter_class=cls, timeout=timeout)
2 changes: 1 addition & 1 deletion src/watchdog/observers/inotify_buffer.py
Expand Up @@ -30,7 +30,7 @@ class InotifyBuffer(BaseThread):
delay = 0.5

def __init__(self, path, recursive=False):
BaseThread.__init__(self)
super().__init__()
self._queue = DelayedQueue(self.delay)
self._inotify = Inotify(path, recursive)
self.start()
Expand Down
4 changes: 2 additions & 2 deletions src/watchdog/observers/kqueue.py
Expand Up @@ -432,7 +432,7 @@ class KqueueEmitter(EventEmitter):

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT,
stat=os.stat):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)

self._kq = select.kqueue()
self._lock = threading.RLock()
Expand Down Expand Up @@ -703,4 +703,4 @@ class KqueueObserver(BaseObserver):
"""

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseObserver.__init__(self, emitter_class=KqueueEmitter, timeout=timeout)
super().__init__(emitter_class=KqueueEmitter, timeout=timeout)
6 changes: 3 additions & 3 deletions src/watchdog/observers/polling.py
Expand Up @@ -66,7 +66,7 @@ class PollingEmitter(EventEmitter):

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT,
stat=os.stat, listdir=os.scandir):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)
self._snapshot = None
self._lock = threading.Lock()
self._take_snapshot = lambda: DirectorySnapshot(
Expand Down Expand Up @@ -125,7 +125,7 @@ class PollingObserver(BaseObserver):
"""

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseObserver.__init__(self, emitter_class=PollingEmitter, timeout=timeout)
super().__init__(emitter_class=PollingEmitter, timeout=timeout)


class PollingObserverVFS(BaseObserver):
Expand All @@ -141,4 +141,4 @@ def __init__(self, stat, listdir, polling_interval=1):
:param polling_interval: interval in seconds between polling the file system.
"""
emitter_cls = partial(PollingEmitter, stat=stat, listdir=listdir)
BaseObserver.__init__(self, emitter_class=emitter_cls, timeout=polling_interval)
super().__init__(emitter_class=emitter_cls, timeout=polling_interval)
5 changes: 2 additions & 3 deletions src/watchdog/observers/read_directory_changes.py
Expand Up @@ -59,7 +59,7 @@ class WindowsApiEmitter(EventEmitter):
"""

def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
super().__init__(event_queue, watch, timeout)
self._lock = threading.Lock()
self._handle = None

Expand Down Expand Up @@ -140,5 +140,4 @@ class WindowsApiObserver(BaseObserver):
"""

def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
BaseObserver.__init__(self, emitter_class=WindowsApiEmitter,
timeout=timeout)
super().__init__(emitter_class=WindowsApiEmitter, timeout=timeout)
2 changes: 1 addition & 1 deletion tests/test_fsevents.py
Expand Up @@ -308,7 +308,7 @@ def test_watchdog_recursive():

class Handler(FileSystemEventHandler):
def __init__(self):
FileSystemEventHandler.__init__(self)
super().__init__()
self.changes = []

def on_any_event(self, event):
Expand Down

0 comments on commit a60ab4f

Please sign in to comment.