From 8dbf6b3ffea6aaf1f698c4b82a171c59c2859b7c Mon Sep 17 00:00:00 2001 From: MaXFeeD Date: Sat, 19 Apr 2025 10:32:43 +0300 Subject: [PATCH] Dynamic explanation in components --- src/icmtoolchain/fetch.py | 2 +- src/icmtoolchain/prompt.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/icmtoolchain/fetch.py b/src/icmtoolchain/fetch.py index 347cee3..7f955d6 100644 --- a/src/icmtoolchain/fetch.py +++ b/src/icmtoolchain/fetch.py @@ -40,7 +40,7 @@ class HttpConnection10: pass def retrieve_stream(input: IO[bytes], output: Optional[IO[bytes]] = None, /, chunk_size: int = 8192, progress_handler: Optional[Callable[[int], None]] = None) -> int: - if chunk_size < -1 or chunk_size == 0: + if chunk_size != -1 and chunk_size < 1: raise ValueError(f"chunk_size should be > 0 or == -1, got {chunk_size}!") with input as stream: received = 0 diff --git a/src/icmtoolchain/prompt.py b/src/icmtoolchain/prompt.py index 6aa6129..2741b7b 100644 --- a/src/icmtoolchain/prompt.py +++ b/src/icmtoolchain/prompt.py @@ -171,7 +171,7 @@ class Input(Feedback): idle_selector_text="", focused_selector_text="" ) - self.explanation_control = Interactable(text=self.explanation, style="class:editable.hint") + self.explanation_control = Interactable(text=lambda: self.explanation, style="class:editable.hint") return HSplit([ self.input_control, @@ -270,7 +270,7 @@ class Select(Feedback): self.focused_interactable = interactable self.choice_variants.append(interactable) which_offset += 1 - self.explanation_control = Interactable(text=self.explanation, style="class:editable.hint") + self.explanation_control = Interactable(text=lambda: self.explanation, style="class:editable.hint") return HSplit([ Interactable(self.prompt),