Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Crash on adding a workspace (only first?) #161

Closed
f88083 opened this issue Jan 6, 2024 · 16 comments
Closed

[BUG] Crash on adding a workspace (only first?) #161

f88083 opened this issue Jan 6, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@f88083
Copy link

f88083 commented Jan 6, 2024

Describe the bug 🐛
Install by pip install dooit turns out it contains old code.

To Reproduce 🐣
Steps to reproduce the behavior:

  1. Install by pip install dooit
  2. run dooit from terminal
  3. image

Expected behavior 🤔
Program can't launch

Desktop (please complete the following information): 🤖

  • OS: Windows10
  • Version 22H2 19045.3803

Python

  • Version: 3.8.10

Additional context 📝
Require manual change the code(from pip install originally) from

from textual.widget import Widget
from dooit.ui.events.events import ChangeStatus, Notify, StatusType
from dooit.utils.keybinder import KeyBinder, KeyList
from dooit.api.model import Result


class KeyWidget(Widget):
    """
    A widget that calls function from keybinder
    """

    def __init__(
        self,
        *children: Widget,
        name: str | None = None,
        id: str | None = None,
        classes: str | None = None,
        disabled: bool = False

to

from typing import Optional
from textual.widget import Widget
from dooit.ui.events.events import ChangeStatus, Notify, StatusType
from dooit.utils.keybinder import KeyBinder, KeyList
from dooit.api.model import Result


class KeyWidget(Widget):
    """
    A widget that calls function from keybinder
    """

    def __init__(
        self,
        *children: Widget,
        name: Optional[str] = None,
        id: Optional[str] = None,
        classes: Optional[str] = None,
        disabled: bool = False

After the change, the program is able to launch

@f88083 f88083 added the bug Something isn't working label Jan 6, 2024
@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Ah this must be due to py 3.8, I think I fixed it but didn't merge into main

Edit: The PyPi package is not updated. Doing rn

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Done! Can you re-check?
Sorry for the inconvenience :(

@f88083
Copy link
Author

f88083 commented Jan 6, 2024

Done! Can you re-check? Sorry for the inconvenience :(

Thank you for the quick fix but here comes another issue

image

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Ah damn I need to bump textual as well. Gimme 5 mins :D

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

One more try :D

@f88083
Copy link
Author

f88083 commented Jan 6, 2024

One more try :D

Another issue🤣🤣🤣
image

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Ok what did you do ?

@f88083
Copy link
Author

f88083 commented Jan 6, 2024

Ok what did you do ?

  1. Launch dooit
  2. press a to add workspace
  3. crash

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Hmmm...That's weird. Can't replicate the same behaviour

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Can you copy paste the whole error and paste it here/somewhere else?
Thanks :D

@f88083
Copy link
Author

f88083 commented Jan 6, 2024

Can you copy paste the whole error and paste it here/somewhere else? Thanks :D

PS C:\Users\f8808> dooit
╭─────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────╮
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\screens\index.py:59 in on_key             │
│                                                                                                                         │
│    56 │   │   event.stop()                                                                                              │
│    57 │   │                                                                                                             │
│    58 │   │   key = self.resolve_key(event)                                                                             │
│ ❱  59 │   │   await self.send_keypress(key)                                                                             │
│    60 │                                                                                                                 │
│    61 │   async def send_keypress(self, key: str):                                                                      │
│    62 │   │   if self.bar.status == "SEARCH":                                                                           │
│                                                                                                                         │
│ ╭───────────────────────────── locals ─────────────────────────────╮                                                    │
│ │ event = Key(key='a', character='a', name='a', is_printable=True) │                                                    │
│ │   key = 'a'                                                      │                                                    │
│ │  self = MainScreen(name='main')                                  │                                                    │
│ ╰──────────────────────────────────────────────────────────────────╯                                                    │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\screens\index.py:66 in send_keypress      │
│                                                                                                                         │
│    63 │   │   │   return await self.query_one(Searcher).keypress(key)                                                   │
│    64 │   │                                                                                                             │
│    65 │   │   visible_focused = [i for i in self.query(".focus") if i.display][0]                                       │
│ ❱  66 │   │   await visible_focused.keypress(key)                                                                       │
│    67 │                                                                                                                 │
│    68 │   async def clear_right(self) -> None:                                                                          │
│    69 │   │   try:                                                                                                      │
│                                                                                                                         │
│ ╭──────────────────────────────────────── locals ─────────────────────────────────────────╮                             │
│ │             key = 'a'                                                                   │                             │
│ │            self = MainScreen(name='main')                                               │                             │
│ │ visible_focused = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31') │                             │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────╯                             │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\widgets\tree.py:493 in keypress           │
│                                                                                                                         │
│   490 │   │   if self.current and self.current._is_editing():                                                           │
│   491 │   │   │   return await self.current.keypress(key)                                                               │
│   492 │   │                                                                                                             │
│ ❱ 493 │   │   await super().keypress(key)                                                                               │
│   494                                                                                                                   │
│                                                                                                                         │
│ ╭─────────────────────────────────── locals ───────────────────────────────────╮                                        │
│ │  key = 'a'                                                                   │                                        │
│ │ self = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31') │                                        │
│ ╰──────────────────────────────────────────────────────────────────────────────╯                                        │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\widgets\base.py:42 in keypress            │
│                                                                                                                         │
│   39 │   │   │   │   if bind.check_for_cursor and not self.is_cursor_available:                                         │
│   40 │   │   │   │   │   return                                                                                         │
│   41 │   │   │   │                                                                                                      │
│ ❱ 42 │   │   │   │   res = await func(*bind.params)                                                                     │
│   43 │   │   │   │   if isinstance(res, Result) and res.message:                                                        │
│   44 │   │   │   │   │   self.post_message(Notify(res.text()))                                                          │
│   45                                                                                                                    │
│                                                                                                                         │
│ ╭──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮     │
│ │ bind = <dooit.utils.keybinder.Bind object at 0x00000273752D49A0>                                                │     │
│ │ func = <bound method Tree.add_sibling of WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31')> │     │
│ │  key = 'a'                                                                                                      │     │
│ │ self = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31')                                    │     │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯     │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\widgets\tree.py:370 in add_sibling        │
│                                                                                                                         │
│   367 │   │   await self.add_node("child")                                                                              │
│   368 │                                                                                                                 │
│   369 │   async def add_sibling(self) -> None:                                                                          │
│ ❱ 370 │   │   await self.add_node("sibling")                                                                            │
│   371 │                                                                                                                 │
│   372 │   async def toggle_expand(self) -> None:                                                                        │
│   373 │   │   if not self.current:                                                                                      │
│                                                                                                                         │
│ ╭─────────────────────────────────── locals ───────────────────────────────────╮                                        │
│ │ self = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31') │                                        │
│ ╰──────────────────────────────────────────────────────────────────────────────╯                                        │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\widgets\tree.py:295 in add_node           │
│                                                                                                                         │
│   292 │   │   self, type_: Literal["child", "sibling"], edit: bool = True                                               │
│   293 │   ) -> None:                                                                                                    │
│   294 │   │   if not self.get_children(self.model) or not self.current:                                                 │
│ ❱ 295 │   │   │   return await self.add_first_child()                                                                   │
│   296 │   │                                                                                                             │
│   297 │   │   if type_ == "child" and not self.current.expanded:                                                        │
│   298 │   │   │   self.current.toggle_expand()                                                                          │
│                                                                                                                         │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮                                       │
│ │  edit = True                                                                  │                                       │
│ │  self = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31') │                                       │
│ │ type_ = 'sibling'                                                             │                                       │
│ ╰───────────────────────────────────────────────────────────────────────────────╯                                       │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\ui\widgets\tree.py:285 in add_first_child    │
│                                                                                                                         │
│   282 │   │   │   self.styles.overflow_x = "auto"                                                                       │
│   283 │   │   │   await i.remove()                                                                                      │
│   284 │   │                                                                                                             │
│ ❱ 285 │   │   child = self.model.add_child(self.ModelType.class_kind)                                                   │
│   286 │   │   new_widget = self.WidgetType(child)                                                                       │
│   287 │   │   await self.mount(new_widget)                                                                              │
│   288 │   │   self.current = new_widget                                                                                 │
│                                                                                                                         │
│ ╭─────────────────────────────────── locals ───────────────────────────────────╮                                        │
│ │    i = EmptyWidget()                                                         │                                        │
│ │ self = WorkspaceTree(id='Tree-manager_cbdf80c9-f486-4b40-814a-783521584d31') │                                        │
│ ╰──────────────────────────────────────────────────────────────────────────────╯                                        │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\api\model.py:249 in add_child                │
│                                                                                                                         │
│   246 │   │   │   │   child._effort._value = 0                                                                          │
│   247 │   │   │   │   child.edit("status", "PENDING")                                                                   │
│   248 │   │                                                                                                             │
│ ❱ 249 │   │   children = self._get_children(kind)                                                                       │
│   250 │   │   children.insert(index, child)                                                                             │
│   251 │   │                                                                                                             │
│   252 │   │   return child                                                                                              │
│                                                                                                                         │
│ ╭──────────────────────────────── locals ─────────────────────────────────╮                                             │
│ │     child = <dooit.api.todo.Todo object at 0x00000273751E76A0>          │                                             │
│ │     index = 0                                                           │                                             │
│ │   inherit = False                                                       │                                             │
│ │      kind = <bound method ? of <class 'dooit.api.workspace.Workspace'>> │                                             │
│ │      self = <dooit.api.manager.Manager object at 0x0000027374ED0AF0>    │                                             │
│ │      Todo = <class 'dooit.api.todo.Todo'>                               │                                             │
│ │ Workspace = <class 'dooit.api.workspace.Workspace'>                     │                                             │
│ ╰─────────────────────────────────────────────────────────────────────────╯                                             │
│                                                                                                                         │
│ C:\Users\f8808\AppData\Local\pipx\pipx\venvs\dooit\lib\site-packages\dooit\api\model.py:126 in _get_children            │
│                                                                                                                         │
│   123 │   │   Get children list (workspace/todo)                                                                        │
│   124 │   │   """
│   125 │   │   if kind not in ["workspace", "todo"]:                                                                     │
│ ❱ 126 │   │   │   raise TypeError(f"Cannot perform this operation for type {kind}")                                     │
│   127 │   │                                                                                                             │
│   128 │   │   return self.workspaces if kind.lower() == "workspace" else self.todos                                     │
│   129                                                                                                                   │
│                                                                                                                         │
│ ╭────────────────────────────── locals ──────────────────────────────╮                                                  │
│ │ kind = <bound method ? of <class 'dooit.api.workspace.Workspace'>> │                                                  │
│ │ self = <dooit.api.manager.Manager object at 0x0000027374ED0AF0>    │                                                  │
│ ╰────────────────────────────────────────────────────────────────────╯                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Cannot perform this operation for type <bound method ? of <class 'dooit.api.workspace.Workspace'>>

@kraanzu
Copy link
Member

kraanzu commented Jan 6, 2024

Ugh, not sure what's going on here. Looks like you're on a windows machine so lemme try that :)

@kraanzu
Copy link
Member

kraanzu commented Jan 12, 2024

Hmm...Can you retry by getting the latest win binary and temporarily remove any configurations that you might've made in the config file :)

@kraanzu kraanzu changed the title [BUG] Install by pip install dooit still get TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' [BUG] Crash on adding a workspace (only first?) Jan 12, 2024
@f88083
Copy link
Author

f88083 commented Jan 15, 2024

Hmm...Can you retry by getting the latest win binary and temporarily remove any configurations that you might've made in the config file :)

win binary works, thank you!

@kraanzu
Copy link
Member

kraanzu commented Jan 15, 2024

Awesome. It's really weird tho
Alright, I'll close this one for now. You can try again from Pip if that works for you or not :D

@kraanzu kraanzu closed this as completed Jan 15, 2024
Copy link

Did we solve your problem?
Glad we could help!

Consider sponsoring my work through github sponsors 😄
@kraanzu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants