Skip to content

Commit

Permalink
restore sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 30, 2024
1 parent 4c25750 commit 52ac87a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3362,10 +3362,11 @@ async def _prune_nodes(self, widgets: list[Widget]) -> None:
Args:
widgets: Widgets to remove.
"""
if not self.is_attached:
return
async with self._dom_lock:
for widget in widgets:
if self.is_attached:
await self._prune_node(widget)
await self._prune_node(widget)

async def _prune_node(self, root: Widget) -> None:
"""Remove a node and its children. Children are removed before parents.
Expand Down
7 changes: 6 additions & 1 deletion src/textual/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ async def _stop_all(cls, timers: Iterable[Timer]) -> None:
timers: A number of timers.
"""

async def stop_timer(timer) -> None:
async def stop_timer(timer: Timer) -> None:
"""Stop a timer and wait for it to finish.
Args:
timer: A Timer instance.
"""
if timer._task is not None:
timer._active.set()
timer._task.cancel()
Expand Down
1 change: 0 additions & 1 deletion src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ def mount(
provided a ``MountError`` will be raised.
"""
if not self.is_attached:
return AwaitMount(self, [])
raise MountError(f"Can't mount widget(s) before {self!r} is mounted")
# Check for duplicate IDs in the incoming widgets
ids_to_mount = [widget.id for widget in widgets if widget.id is not None]
Expand Down

0 comments on commit 52ac87a

Please sign in to comment.