Skip to content

Commit

Permalink
fix: mypy errors introduced by #1012 (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
msabramo committed Oct 9, 2023
1 parent 5f9d93c commit 2338837
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/watchdog/observers/polling.py
Expand Up @@ -49,7 +49,7 @@
FileMovedEvent,
)
from watchdog.observers.api import DEFAULT_EMITTER_TIMEOUT, DEFAULT_OBSERVER_TIMEOUT, BaseObserver, EventEmitter
from watchdog.utils.dirsnapshot import DirectorySnapshot, DirectorySnapshotDiff
from watchdog.utils.dirsnapshot import DirectorySnapshot, DirectorySnapshotDiff, EmptyDirectorySnapshot


class PollingEmitter(EventEmitter):
Expand All @@ -68,7 +68,7 @@ def __init__(
listdir=os.scandir,
):
super().__init__(event_queue, watch, timeout, event_filter)
self._snapshot = None
self._snapshot: DirectorySnapshot = EmptyDirectorySnapshot()
self._lock = threading.Lock()
self._take_snapshot = lambda: DirectorySnapshot(
self.watch.path, self.watch.is_recursive, stat=stat, listdir=listdir
Expand Down
5 changes: 4 additions & 1 deletion src/watchdog/utils/dirsnapshot.py
Expand Up @@ -356,12 +356,15 @@ def __repr__(self) -> str:
return str(self._stat_info)


class EmptyDirectorySnapshot:
class EmptyDirectorySnapshot(DirectorySnapshot):
"""Class to implement an empty snapshot. This is used together with
DirectorySnapshot and DirectorySnapshotDiff in order to get all the files/folders
in the directory as created.
"""

def __init__(self):
pass

@staticmethod
def path(_: Any) -> None:
"""Mock up method to return the path of the received inode. As the snapshot
Expand Down

0 comments on commit 2338837

Please sign in to comment.