Skip to content
Discussion options

You must be logged in to vote

The proper type for start_time would be reactive[float]:

diff --git a/docs/examples/tutorial/stopwatch05.py b/docs/examples/tutorial/stopwatch05.py
index 19f6366f7..66a2162a2 100644
--- a/docs/examples/tutorial/stopwatch05.py
+++ b/docs/examples/tutorial/stopwatch05.py
@@ -9,7 +9,7 @@ from textual.widgets import Button, Footer, Header, Static
 class TimeDisplay(Static):
     """A widget to display elapsed time."""
 
-    start_time = reactive(monotonic)
+    start_time: reactive[float] = reactive(monotonic)
     time = reactive(0.0)
 
     def on_mount(self) -> None:

The reason is start_time is using monotonic as a dynamic default and monotinic returns a float. This also explains why mypy…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lauralindzey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants