Skip to content

Commit a15d931

Browse files
Update event_types parameter in FileWatcher (#89)
2 parents 696fa52 + d2b6d9f commit a15d931

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

.github/RELEASE_NOTES.template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including if there are any depractions and what they should be replaced with -->
9+
<!-- Here goes notes on how to upgrade from previous versions, including if there are any deprecations and what they should be replaced with -->
1010

1111
## New Features
1212

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including if there are any depractions and what they should be replaced with -->
9+
* `FileWatcher` no longer accepts or sets `None` as the `event_types` argument. Instead, all available event types are now set by default while still providing the flexibility to customize the event types as needed.
1010

1111
## New Features
1212

src/frequenz/channels/util/_file_watcher.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import asyncio
99
import pathlib
10+
from collections import abc
1011
from dataclasses import dataclass
1112
from enum import Enum
1213

@@ -39,19 +40,16 @@ class Event:
3940
def __init__(
4041
self,
4142
paths: list[pathlib.Path | str],
42-
event_types: set[EventType] | None = None,
43+
event_types: abc.Iterable[EventType] = frozenset(EventType),
4344
) -> None:
4445
"""Create a `FileWatcher` instance.
4546
4647
Args:
4748
paths: Paths to watch for changes.
48-
event_types: Types of events to watch for or `None` to watch for
49+
event_types: Types of events to watch for. Defaults to watch for
4950
all event types.
5051
"""
51-
if event_types is None:
52-
event_types = set(FileWatcher.EventType) # all types
53-
54-
self.event_types = event_types
52+
self.event_types: frozenset[FileWatcher.EventType] = frozenset(event_types)
5553
self._stop_event = asyncio.Event()
5654
self._paths = [
5755
path if isinstance(path, pathlib.Path) else pathlib.Path(path)

0 commit comments

Comments
 (0)