dooit-org / dooit

An awesome TUI todo manager
MIT License
2.1k stars 97 forks source link

[BUG] ValueError in Dooit: SCREENS Contains Instance Instead of Callable Screen Type #198

Open zx0r opened 2 days ago

zx0r commented 2 days ago

Hi bro)

Describe the bug πŸ› Dooit Initialization Error: SCREENS Configuration Incorrectly Uses Instance

Desktop Environment πŸ‘½
 - OS: Gentoo Base System release 2.16
 - Linux unixp0rn 6.11.5-gentoo-x86_64
 - XDG_SESSION_TYPE: wayland
 - Window Manager: Hyprland

# sudo -e /usr/lib/python3.12/site-packages/dooit/ui/tui.py
# error 🚫
 ------------------------------------------------------------------------------
# class Dooit(App):
#     CSS = screen_CSS
#     SCREENS = {
#         "main": MainScreen(name="main"),
#         "help": HelpScreen(name="help"),
#     }
# fix βœ…
 ------------------------------------------------------------------------------
class Dooit(App):
    CSS = screen_CSS
    # Reference the screen classes without instantiating them
    SCREENS = {
        "main": MainScreen,  # Use the class directly
        "help": HelpScreen,  # Use the class directly
    }

Additional context πŸ“ The error traceback indicated that the issue was caused by incorrectly instantiating the screens within the SCREENS dictionary. To fix this, the SCREENS declaration was modified to only include the class references without instantiation:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/dooit", line 5, in <module>
    from dooit.__main__ import main
  File "/usr/lib/python3.12/site-packages/dooit/__main__.py", line 3, in <module>
    from dooit.ui.tui import Dooit
  File "/usr/lib/python3.12/site-packages/dooit/ui/tui.py", line 17, in <module>
    class Dooit(App):
  File "/usr/lib/python3.12/site-packages/textual/message_pump.py", line 109, in __new__
    class_obj = super().__new__(cls, name, bases, class_dict, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/textual/app.py", line 790, in __init_subclass__
    raise ValueError(
ValueError: SCREENS should contain a Screen type or callable, not an instance (got instance of MainScreen for 'main')

Screenshots πŸ“Ί

captura-2024-11-05-1730815042 captura-2024-11-05-1730816716 captura-2024-11-05-1730815148

kraanzu commented 2 days ago

Hi @zx0r , Yes The current version uses a very old release of Textual, the underlying TUI library hence the issue. How are you installing dooit? The version needs to be pinned if you're using distro-specific package manager. No idea about gentoo sorry, I guess it was emerge ? Can you share some details?

Plus, I'll make a new release tomm so things should sort out when the package is updated:)

zx0r commented 2 days ago

Portage package manager priority)

captura-2024-11-05-1730831026