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

watson edit barfs with TypeError #30

Closed
waynew opened this issue Oct 17, 2015 · 2 comments
Closed

watson edit barfs with TypeError #30

waynew opened this issue Oct 17, 2015 · 2 comments
Labels

Comments

@waynew
Copy link
Contributor

waynew commented Oct 17, 2015

Under Python 3.4.3 & arch linux, with watson installed in a venv:

$ watson edit

<opens up vim session, simply write and quit>

💥

Traceback (most recent call last):
  File "/home/wayne/.virtualenvs/myenv/bin/watson", line 7, in <module>
    from watson.__main__ import cli
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/watson/__main__.py", line 6, in <module>
    cli.cli()
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/core.py", line 700, in __call__
    return self.main(*args, **kwargs)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/core.py", line 680, in main
    rv = self.invoke(ctx)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/core.py", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/core.py", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/watson/cli.py", line 544, in edit
    watson.frames[id] = (project, start, stop, tags)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/watson/frames.py", line 105, in __setitem__
    self._rows[self._get_index_by_id(key)] = frame
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/watson/frames.py", line 120, in _get_index_by_id
    i for i, v in enumerate(self['id']) if v.startswith(id)
  File "/home/wayne/.virtualenvs/myenv/lib/python3.4/site-packages/watson/frames.py", line 120, in <genexpr>
    i for i, v in enumerate(self['id']) if v.startswith(id)
TypeError: startswith first arg must be str or a tuple of str, not NoneType
@jmaupetit jmaupetit added the bug label Oct 17, 2015
@waynew
Copy link
Contributor Author

waynew commented Oct 17, 2015

Pinpointed the cause:

If you look here you'll see that if you provide no id it will just use the previous frame if it can:

    if not id:
        try:
            frame = watson.frames[-1]
        except IndexError:
            raise click.ClickException(
                "No frame to edit. It's time to create your first one!"
            )

but it never sets the id, so when we try to use the id later, it's None.

That should probably be:

frame = watson.frames[-1]
id = frame.id

(and adding that line locally seems to make it work)

@SpotlightKid
Copy link
Contributor

Just stumbled over this too, so can I confirm the error and that the solution fixes it for me too.

Thanks for finding a solution!

willdurand added a commit that referenced this issue Oct 17, 2015
loonies pushed a commit to loonies/Watson that referenced this issue Feb 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants