Skip to content

Commit

Permalink
type lifecycle hooks and extend test
Browse files Browse the repository at this point in the history
  • Loading branch information
Korijn committed Nov 16, 2023
1 parent c6647ad commit ab07c4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions observ/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class Watcher:
"_number_of_callback_args",
"__weakref__",
]
on_created = None
on_destroyed = None
on_created: Optional[Callable[[Watcher], None]] = None
on_destroyed: Optional[Callable[[Watcher], None]] = None

def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions tests/test_watcher_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _callback():
called += 1

watch(lambda: len(a), _callback, sync=True)
assert len(watchers) == 1
assert called == 0
a.append(3)
assert called == 1
Expand Down

0 comments on commit ab07c4d

Please sign in to comment.