From b2cc030953584a554c90d2bf6465ea7fd3551cc2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Jun 2026 10:55:25 +0000 Subject: [PATCH] fix(tui): convert COMMANDS list to immutable tuple Converts the module-level COMMANDS list to a tuple to prevent accidental mutation at runtime. Updates test assertion to expect tuple. Addresses item from code quality report. Related to #766 Co-authored-by: openhands --- openhands_cli/tui/core/commands.py | 4 ++-- tests/tui/test_commands.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openhands_cli/tui/core/commands.py b/openhands_cli/tui/core/commands.py index 41aa2bf2a..58d7eee22 100644 --- a/openhands_cli/tui/core/commands.py +++ b/openhands_cli/tui/core/commands.py @@ -15,7 +15,7 @@ # Available commands with descriptions after the command -COMMANDS = [ +COMMANDS: tuple[DropdownItem, ...] = ( DropdownItem(main="/help - Display available commands"), DropdownItem(main="/new - Start a new conversation"), DropdownItem(main="/history - Toggle conversation history"), @@ -25,7 +25,7 @@ DropdownItem(main="/skills - View loaded skills, hooks, and MCPs"), DropdownItem(main="/feedback - Send anonymous feedback about CLI"), DropdownItem(main="/exit - Exit the application"), -] +) def get_valid_commands() -> set[str]: diff --git a/tests/tui/test_commands.py b/tests/tui/test_commands.py index 186001380..c5f8b55c6 100644 --- a/tests/tui/test_commands.py +++ b/tests/tui/test_commands.py @@ -32,8 +32,8 @@ class TestCommands: """Tests for command definitions and handlers.""" def test_commands_list_structure(self): - """Test that COMMANDS list has correct structure.""" - assert isinstance(COMMANDS, list) + """Test that COMMANDS tuple has correct structure.""" + assert isinstance(COMMANDS, tuple) assert len(COMMANDS) == 9 # Check that all items are DropdownItems