From 8eca82c6f19144e81f57c3310588ff1240c0179f Mon Sep 17 00:00:00 2001 From: QuantumEnergyE Date: Wed, 30 Nov 2022 23:20:39 +0800 Subject: [PATCH] Remove unnecessary code of dirsnapshot.py --- src/watchdog/utils/dirsnapshot.py | 3 +-- tests/test_snapshot_diff.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/watchdog/utils/dirsnapshot.py b/src/watchdog/utils/dirsnapshot.py index 8b499694..5a4e1e8e 100644 --- a/src/watchdog/utils/dirsnapshot.py +++ b/src/watchdog/utils/dirsnapshot.py @@ -255,8 +255,7 @@ def __init__(self, path, recursive=True, def walk(self, root): try: - paths = [os.path.join(root, entry if isinstance(entry, str) else entry.name) - for entry in self.listdir(root)] + paths = [os.path.join(root, entry.name) for entry in self.listdir(root)] except OSError as e: # Directory may have been deleted between finding it in the directory # list of its parent and trying to delete its contents. If this diff --git a/tests/test_snapshot_diff.py b/tests/test_snapshot_diff.py index 850f3aed..45303d19 100644 --- a/tests/test_snapshot_diff.py +++ b/tests/test_snapshot_diff.py @@ -130,7 +130,7 @@ def listdir_fcn(path): if path == p("root", "dir"): rm(path, recursive=True) touch(path) - return os.listdir(path) + return os.scandir(path) mkdir(p('root')) mkdir(p('root', 'dir'))