Skip to content

Commit 2540859

Browse files
zza-830Ziang ZhangAkshajSinghal
authored
fix: resolve NameError in settings Appearance tab by defining select_widget (#51)
* fix: resolve NameError in settings Appearance tab by defining select_widget The method created a Select widget inline inside but then referenced an undefined variable to call and add a duplicate field, causing a NameError crash whenever the Appearance category was selected. Fix: store the Select widget in a local variable before passing it to , and remove the duplicate field addition. Closes #42 * test: fix help docs test by adding _import_module to fake kernel The test_run_help_prints_docstring_for_known_command test was failing because the fake kernel lacked a _import_module method, causing the module import to fail silently and fall through to the error message. Add a working _fake_import_module that uses importlib to resolve the module path, allowing run_help to read and print the docstring. * fix: resolve NameError crash at startup by defining argv before use The function referenced a bare name that was never imported or defined, causing a NameError crash on every invocation. Fix: move before the conditional block so it is always defined when reached by the comparison at the end of the function. Closes #40 * fix: remove dead _fake_import_module from test --------- Co-authored-by: Ziang Zhang <zhangziang@ncti-gba.cn> Co-authored-by: Akshaj Singhal <85437940+AkshajSinghal@users.noreply.github.com>
1 parent 8d16375 commit 2540859

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

trushell/cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def app_with_lower() -> None:
2929
if len(sys.argv) > 1:
3030
argv_copy = sys.argv.copy()
3131
if argv_copy[1].lower() not in {"--help", "-h", "version"}:
32-
# Normalize the command name to lowercase for case-insensitive
33-
# invocation, but preserve the case of subsequent arguments
34-
# (e.g., filenames) which may be case-sensitive.
3532
first = argv_copy[1].lower()
3633
rest = argv_copy[2:]
3734
raw = " ".join([first] + rest)

trushell/commands/settings.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,11 @@ def add_field(label_text: str, widget: Static | Input | Select | Switch) -> None
167167
Input(value=str(self.dirty_settings.get("prompt_symbol", self.settings.get("prompt_symbol", "➜"))), id="prompt_symbol"),
168168
)
169169
elif current_cat == "Appearance":
170-
add_field(
171-
"Theme:",
172-
Select(
173-
options=self.THEME_OPTIONS,
174-
value=str(self.dirty_settings.get("theme", self.settings.get("theme", "dark"))),
175-
id="theme_selector",
176-
),
170+
select_widget = Select(
171+
options=self.THEME_OPTIONS,
172+
value=str(self.dirty_settings.get("theme", self.settings.get("theme", "dark"))),
173+
id="theme_selector",
177174
)
178-
select_widget.watch_value(lambda value: self._track_change("theme", value))
179175
add_field("Theme:", select_widget)
180176
elif current_cat == "Navigation":
181177
add_field(

0 commit comments

Comments
 (0)