Skip to content

[BUG] AttributeError: 'Option' object has no attribute 'set_prompt' #229

@ghost

Description

Description:
When running the dooit application, an AttributeError occurs because the Option object does not have a method set_prompt. This happens during the execution of the refresh_options method in model_tree.py.

Steps to Reproduce:

  1. Install dooit using yay installation method.
    
  2. Run the application with the command: dooit
    
  3. The error occurs during the refresh of workspace options, which triggers the issue.
    

Error Details:

Traceback (most recent call last):
File "/usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py", line 158, in on_mount
self.force_refresh()
File "/usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py", line 129, in force_refresh
self._force_refresh()
File "/usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py", line 155, in _force_refresh
self.refresh_options()
File "/usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py", line 222, in refresh_options
i.set_prompt(self._renderers[i.id].prompt)
AttributeError: 'Option' object has no attribute 'set_prompt'

Full output:

$ dooit
╭────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────╮
│ /usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py:158 in on_mount │
│ │
│ 155 │ │ self.refresh_options() │
│ 156 │ │
│ 157 │ def on_mount(self): │
│ ❱ 158 │ │ self.force_refresh() │
│ 159 │ │
│ 160 │ @require_highlighted_node │
│ 161 │ def start_sort(self): │
│ │
│ ╭──────────────────────── locals ────────────────────────╮ │
│ │ self = WorkspacesTree(id='WorkspacesTree_Workspace_1') │ │
│ ╰────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/_decorators.py:17 in wrapper │
│ │
│ 14 │ │ highlighted_id = self.node.id if self.highlighted is not None else None │
│ 15 │ │ highlighted_index = self.highlighted │
│ 16 │ │ │
│ ❱ 17 │ │ func(self, *args, **kwargs) │
│ 18 │ │ │
│ 19 │ │ try: │
│ 20 │ │ │ if highlighted_id is None: │
│ │
│ ╭────────────────────────────── locals ───────────────────────────────╮ │
│ │ args = () │ │
│ │ highlighted_id = None │ │
│ │ highlighted_index = None │ │
│ │ kwargs = {} │ │
│ │ self = WorkspacesTree(id='WorkspacesTree_Workspace_1') │ │
│ ╰─────────────────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py:129 in force_refresh │
│ │
│ 126 │ │
│ 127 │ @fix_highlight │
│ 128 │ def force_refresh(self) -> None: │
│ ❱ 129 │ │ self._force_refresh() │
│ 130 │ │ self.get_column_width.cache_clear() │
│ 131 │ │
│ 132 │ def _force_refresh(self) -> None: │
│ │
│ ╭──────────────────────── locals ────────────────────────╮ │
│ │ self = WorkspacesTree(id='WorkspacesTree_Workspace_1') │ │
│ ╰────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py:155 in _force_refresh │
│ │
│ 152 │ │ │
│ 153 │ │ has_options = bool(options) │
│ 154 │ │ self.empty_message.display = not has_options │
│ ❱ 155 │ │ self.refresh_options() │
│ 156 │ │
│ 157 │ def on_mount(self): │
│ 158 │ │ self.force_refresh() │
│ │
│ ╭─────────────────────────── locals ────────────────────────────╮ │
│ │ has_options = True │ │
│ │ highlighted = None │ │
│ │ options = [ │ │
│ │ │ Option('', id='Workspace_2'), │ │
│ │ │ Option('', id='Workspace_11'), │ │
│ │ │ Option('', id='Workspace_15'), │ │
│ │ │ Option('', id='Workspace_3'), │ │
│ │ │ Option('', id='Workspace_4'), │ │
│ │ │ Option('', id='Workspace_5'), │ │
│ │ │ Option('', id='Workspace_7'), │ │
│ │ │ Option('', id='Workspace_8'), │ │
│ │ │ Option('', id='Workspace_9'), │ │
│ │ │ Option('', id='Workspace_10'), │ │
│ │ │ ... +2 │ │
│ │ ] │ │
│ │ self = WorkspacesTree(id='WorkspacesTree_Workspace_1') │ │
│ ╰───────────────────────────────────────────────────────────────╯ │
│ │
│ /usr/lib/python3.13/site-packages/dooit/ui/widgets/trees/model_tree.py:222 in refresh_options │
│ │
│ 219 │ │ │ assert i.id is not None │
│ 220 │ │ │ new_prompt = self._renderers[i.id].prompt │
│ 221 │ │ │ if i.prompt != new_prompt: │
│ ❱ 222 │ │ │ │ i.set_prompt(self._renderers[i.id].prompt) │
│ 223 │ │ │
│ 224 │ │ self._refresh_lines() │
│ 225 │
│ │
│ ╭─────────────────────────── locals ───────────────────────────╮ │
│ │ i = Option('', id='Workspace_2') │ │
│ │ new_prompt = <rich.table.Table object at 0x7b95602decf0> │ │
│ │ self = WorkspacesTree(id='WorkspacesTree_Workspace_1') │ │
│ ╰──────────────────────────────────────────────────────────────╯ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Option' object has no attribute 'set_prompt'

NOTE: 1 of 2 errors shown. Run with textual run --dev to see all errors.

Expected Behavior: The Option object should either have a set_prompt method, or the code should check if this method exists before attempting to call it. This would prevent the AttributeError from occurring.

Environment:

  • Python version: 3.13
    
  • dooit version: 3.1.0
    
  • OS: Arch Linux
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions