Skip to content

Commit 5460a2a

Browse files
BoboTiGTobiasRzepka
authored andcommitted
fix: lint + types + tests (gorakhargosh#1102)
1 parent 30a0efa commit 5460a2a

File tree

5 files changed

+8
-18
lines changed

5 files changed

+8
-18
lines changed

src/watchdog/observers/inotify.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ class InotifyWatchGroup(WatchCallback):
144144
"""The inotify instance to use"""
145145
path: bytes
146146
"""Whether we are watching directories recursively."""
147-
event_mask: Mask = field(kw_only=True)
147+
event_mask: Mask = field(default=Mask(0))
148148
"""The path associated with the inotify instance."""
149-
is_recursive: bool = field(default=False, kw_only=True)
149+
is_recursive: bool = False
150150
"""The event mask for this inotify instance."""
151-
follow_symlink: bool = field(default=False, kw_only=True)
151+
follow_symlink: bool = False
152152

153153
_move_event_grouper: InotifyMoveEventGrouper = field(default_factory=InotifyMoveEventGrouper, init=False)
154154
_lock: threading.Lock = field(default_factory=threading.Lock, init=False)

src/watchdog/observers/inotify_move_event_grouper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PathedInotifyEvent(NamedTuple):
2828
path: bytes
2929

3030

31-
GroupedInotifyEvent: TypeAlias = Union[PathedInotifyEvent | tuple[PathedInotifyEvent, PathedInotifyEvent]]
31+
GroupedInotifyEvent: TypeAlias = Union[PathedInotifyEvent, tuple[PathedInotifyEvent, PathedInotifyEvent]]
3232

3333

3434
class InotifyMoveEventGrouper:

src/watchdog/utils/patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _get_sep(path: PurePath) -> str:
3838

3939
def _full_match(path: PurePath, pattern: str) -> bool:
4040
try:
41-
return path.full_match(pattern) # type: ignore[attr-defined]
41+
return path.full_match(pattern)
4242
except AttributeError:
4343
# Replicate for python <3.13
4444
# Please remove this, backwards_compat.py, and python license attributions

tests/test_snapshot_diff.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_move_to(p):
3838
ref = DirectorySnapshot(p("dir2"))
3939
mv(p("dir1", "a"), p("dir2", "b"))
4040
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("dir2")))
41-
assert len(diff) == 2
4241
assert diff.files_created == [p("dir2", "b")]
4342

4443

@@ -52,8 +51,6 @@ def test_move_to_with_context_manager(p):
5251
with dir1_cm, dir2_cm:
5352
mv(p("dir1", "a"), p("dir2", "b"))
5453

55-
assert len(dir1_cm.diff) == 2
56-
assert len(dir2_cm.diff) == 2
5754
assert dir1_cm.diff.files_deleted == [p("dir1", "a")]
5855
assert dir2_cm.diff.files_created == [p("dir2", "b")]
5956

@@ -65,7 +62,6 @@ def test_move_from(p):
6562
ref = DirectorySnapshot(p("dir1"))
6663
mv(p("dir1", "a"), p("dir2", "b"))
6764
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("dir1")))
68-
assert len(diff) == 2
6965
assert diff.files_deleted == [p("dir1", "a")]
7066

7167

@@ -76,7 +72,6 @@ def test_move_internal(p):
7672
ref = DirectorySnapshot(p(""))
7773
mv(p("dir1", "a"), p("dir2", "b"))
7874
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("")))
79-
assert len(diff) == 3
8075
assert diff.files_moved == [(p("dir1", "a"), p("dir2", "b"))]
8176
assert diff.files_created == []
8277
assert diff.files_deleted == []
@@ -90,7 +85,6 @@ def test_move_replace(p):
9085
ref = DirectorySnapshot(p(""))
9186
mv(p("dir1", "a"), p("dir2", "b"))
9287
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("")))
93-
assert len(diff) == 3
9488
assert diff.files_moved == [(p("dir1", "a"), p("dir2", "b"))]
9589
assert diff.files_deleted == [p("dir2", "b")]
9690
assert diff.files_created == []
@@ -101,7 +95,6 @@ def test_dir_modify_on_create(p):
10195
wait()
10296
touch(p("a"))
10397
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("")))
104-
assert len(diff) == 2
10598
assert diff.dirs_modified == [p("")]
10699

107100

@@ -113,7 +106,6 @@ def test_dir_modify_on_move(p):
113106
wait()
114107
mv(p("dir1", "a"), p("dir2", "b"))
115108
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("")))
116-
assert len(diff) == 3
117109
assert set(diff.dirs_modified) == {p("dir1"), p("dir2")}
118110

119111

@@ -124,7 +116,6 @@ def test_detect_modify_for_moved_files(p):
124116
touch(p("a"))
125117
mv(p("a"), p("b"))
126118
diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p("")))
127-
assert len(diff) == 3
128119
assert diff.files_moved == [(p("a"), p("b"))]
129120
assert diff.files_modified == [p("a")]
130121

@@ -199,7 +190,6 @@ def inode(self, path):
199190
# be different), it thinks that the same file has been deleted and created again.
200191
snapshot = DirectorySnapshot(p(""))
201192
diff_with_device = DirectorySnapshotDiff(ref, snapshot)
202-
assert len(diff_with_device) == 4
203193
assert diff_with_device.files_deleted == [(p("file"))]
204194
assert diff_with_device.files_created == [(p("file"))]
205195

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ commands =
5151
python -m mypy --platform freebsd --disable-error-code unused-ignore \
5252
src/watchdog/observers/kqueue.py
5353
python -m mypy --platform linux --disable-error-code unused-ignore \
54-
src/watchdog/observers/inotify.py \
55-
src/watchdog/observers/inotify_buffer.py \
56-
src/watchdog/observers/inotify_c.py
54+
src/watchdog/observers/inotify_c.py \
55+
src/watchdog/observers/inotify_move_event_grouper.py \
56+
src/watchdog/observers/inotify.py
5757
python -m mypy --platform win32 --disable-error-code unused-ignore \
5858
src/watchdog/observers/read_directory_changes.py \
5959
src/watchdog/observers/winapi.py

0 commit comments

Comments
 (0)