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

TypeError: __init__() takes 6 positional arguments but 7 were given #2

Closed
kratsg opened this issue Mar 7, 2023 · 3 comments · Fixed by #3
Closed

TypeError: __init__() takes 6 positional arguments but 7 were given #2

kratsg opened this issue Mar 7, 2023 · 3 comments · Fixed by #3

Comments

@kratsg
Copy link
Contributor

kratsg commented Mar 7, 2023

Versions

rich==13.3.2
textual==0.11.1
textual-filedrop==0.3.0

Broken

Running the fullscreen.py example gives me this traceback when I drag and drop a single file into the fullscreen widget. I tried to look at the code quickly to understand why, since it's clearly giving the right number of arguments, but I could not figure out why it would be wrong.

╭─────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────╮
│ /Users/kratsg/itkdb-tutorial-march2023/venv/lib/python3.8/site-packages/textual_filedrop/_filedrop.py:97 in      │
│ on_event                                                                                                         │
│                                                                                                                  │
│    94 │   │   │   filepaths = _extract_filepaths(event.text)                                                     │
│    95 │   │   │   if filepaths:                                                                                  │
│    96 │   │   │   │   filesobj = _build_filesobj(filepaths)                                                      │
│ ❱  97 │   │   │   │   await self._post_message(filepaths, filesobj)                                              │
│    98 │                                                                                                          │
│    99 │   async def _post_message(                                                                               │
│   100 │   │   self, filepaths: List[str], filesobj: List[Dict[str, Any]]                                         │
│                                                                                                                  │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮                                │
│ │     event = Paste(text='/Users/kratsg/Downloads/epqinAll311Feb2023.png ')     │                                │
│ │ filepaths = ['/Users/kratsg/Downloads/epqinAll311Feb2023.png']                │                                │
│ │  filesobj = [                                                                 │                                │
│ │             │   {                                                             │                                │
│ │             │   │   'path': '/Users/kratsg/Downloads/epqinAll311Feb2023.png', │                                │
│ │             │   │   'name': 'epqinAll311Feb2023.png',                         │                                │
│ │             │   │   'ext': 'png',                                             │                                │
│ │             │   │   'icon': '\uf1c5'                                          │                                │
│ │             │   }                                                             │                                │
│ │             ]                                                                 │                                │
│ │      self = FileDrop(id='filedrop', pseudo_classes={'focus-within'})          │                                │
│ ╰───────────────────────────────────────────────────────────────────────────────╯                                │
│                                                                                                                  │
│ /Users/kratsg/itkdb-tutorial-march2023/venv/lib/python3.8/site-packages/textual_filedrop/_filedrop.py:110 in     │
│ _post_message                                                                                                    │
│                                                                                                                  │
│   107 │   │   │   ]                                                                                              │
│   108 │   │   )                                                                                                  │
│   109 │   │   await self.post_message(                                                                           │
│ ❱ 110 │   │   │   self.Dropped(                                                                                  │
│   111 │   │   │   │   self,                                                                                      │
│   112 │   │   │   │   os.path.split(filepaths[0])[0],                                                            │
│   113 │   │   │   │   filepaths,                                                                                 │
│                                                                                                                  │
│ ╭──────────────────────────────────── locals ────────────────────────────────────╮                               │
│ │ filenames = ['epqinAll311Feb2023.png']                                         │                               │
│ │ filepaths = ['/Users/kratsg/Downloads/epqinAll311Feb2023.png']                 │                               │
│ │  filesobj = [                                                                  │                               │
│ │             │   {                                                              │                               │
│ │             │   │   'path': '/Users/kratsg/Downloads/epqinAll311Feb2023.png',  │                               │
│ │             │   │   'name': 'epqinAll311Feb2023.png',                          │                               │
│ │             │   │   'ext': 'png',                                              │                               │
│ │             │   │   'icon': '\uf1c5'                                           │                               │
│ │             │   }                                                              │                               │
│ │             ]                                                                  │                               │
│ │   oneline = '[on dodger_blue3] \uf1c5 [/][on gray27]epqinAll311Feb2023.png[/]' │                               │
│ │      self = FileDrop(id='filedrop', pseudo_classes={'focus-within'})           │                               │
│ ╰────────────────────────────────────────────────────────────────────────────────╯                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: __init__() takes 6 positional arguments but 7 were given
@kratsg
Copy link
Contributor Author

kratsg commented Mar 7, 2023

Update: looks like I had an older pip that didn't resolve that upper bound from this package. Sorry for the noise. Seems to not crash on textual==0.11.1. Nope, still crashes.

@kratsg kratsg closed this as completed Mar 7, 2023
@kratsg kratsg reopened this Mar 7, 2023
@kratsg
Copy link
Contributor Author

kratsg commented Mar 7, 2023

Ahh, the issue is that self.Dropped passes in self as the first argument already, hence the error. Dropping oneline fixes it.

@agmmnn
Copy link
Owner

agmmnn commented Mar 7, 2023

Ahh, the issue is that self.Dropped passes in self as the first argument already, hence the error. Dropping oneline fixes it.

Yes it was my mistake I forgot to pass it as an argument to init. Instead of dropping I added it to arguments. Thank you for the issue/pr. @kratsg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants