Skip to content

Commit cad7f25

Browse files
committed
fix: repr(EmptyDirectorySnapshot)
It was throwing: AttributeError: 'EmptyDirectorySnapshot' object has no attribute '_stat_info'. Reported by an anonymous crontributor in the shadow :)
1 parent ad0d055 commit cad7f25

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changelog
99
202x-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v6.0.0...HEAD>`__
1010

1111
- Adjust ``Observer.schedule()`` ``path`` type annotation to reflect the ``pathlib.Path`` support. (`#1096 <https://github.com/gorakhargosh/watchdog/pull/1096>`__)
12+
- [utils] Fixed ``repr(EmptyDirectorySnapshot)``, before that it was throwing an ``AttributeError: 'EmptyDirectorySnapshot' object has no attribute '_stat_info'``.
1213
- Thanks to our beloved contributors: @BoboTiG, @tybug
1314

1415
**Breaking Changes**

src/watchdog/utils/dirsnapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class EmptyDirectorySnapshot(DirectorySnapshot):
401401
"""
402402

403403
def __init__(self) -> None:
404-
pass
404+
self._stat_info: dict[bytes | str, os.stat_result] = {}
405405

406406
@staticmethod
407407
def path(_: Any) -> None:

tests/test_snapshot_diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def test_empty_snapshot(p):
210210
mkdir(p("b", "c"), parents=True)
211211
ref = DirectorySnapshot(p(""))
212212
empty = EmptyDirectorySnapshot()
213+
assert repr(empty) == "{}"
213214

214215
diff = DirectorySnapshotDiff(empty, ref)
215216
assert diff.files_created == [p("a")]

0 commit comments

Comments
 (0)