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

Fix completions broken since click>=8 #473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

voidus
Copy link

@voidus voidus commented May 24, 2022

Quoting click changelog for 8.0.0

The env var values used to start completion have changed order. The shell now comes first, such as {shell}source rather than > source{shell}, and is always required.

I think this fix warrants a 2.1.1 release, since missing completions are kind of a big deal for a lot of people. (Shamelessly generalizing from my experience)

@voidus
Copy link
Author

voidus commented May 24, 2022

Having some other issues with completion:

    from watson.__main__ import cli
  File "/nix/store/0qj8zhf7pklvwcq3ix60pa3cb9vcdcly-watson-2.1.0/lib/python3.9/site-packages/watson/__main__.py", line 3, in <module>
    cli.cli()
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1050, in main
    self._main_shell_completion(extra, prog_name, complete_var)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1125, in _main_shell_completion
    rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 49, in shell_complete
    echo(comp.complete())
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 291, in complete
    completions = self.get_completions(args, incomplete)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 273, in get_completions
    return obj.shell_complete(ctx, incomplete)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 2397, in shell_complete
    results = self._custom_shell_complete(ctx, self, incomplete)
  File "/nix/store/0qj8zhf7pklvwcq3ix60pa3cb9vcdcly-watson-2.1.0/lib/python3.9/site-packages/watson/autocompletion.py", line 51, in get_project_or_task_completion
    tok.startswith("+") for tok in args + [incomplete]
TypeError: unsupported operand type(s) for +: 'Argument' and 'list'

so I'll mark this WIP for now

@voidus voidus changed the title Fix completions broken since click>=8 WIP: Fix completions broken since click>=8 May 24, 2022
@jmaupetit
Copy link
Member

Thanks you for this @voidus 🙏 Keep it up 💪

@voidus
Copy link
Author

voidus commented Jun 6, 2022

Okay this was a bit of a ride, I ended up mostly rewriting the completion.

I started implementing it while respecting the multi-word features (that is, being able to enter watson add my cool project +and a tag +another tag without putting quotes, but there are so many edge cases it's crazy.

Finally, I ended up ignoring it, because it was not consistently supported anyways.
Both as a developer and a user, I would advise to officially drop that feature.

But that's not the point here. It would be great if you could have a look and let me know what you think, I ended up changing more than I planned.

@voidus
Copy link
Author

voidus commented Jun 6, 2022

squashed the two commits

@voidus voidus changed the title WIP: Fix completions broken since click>=8 Fix completions broken since click>=8 Jun 6, 2022
@voidus voidus removed their assignment Jun 13, 2022
@voidus
Copy link
Author

voidus commented Jun 13, 2022

@jmaupetit could you have a look please?

@soltysh
Copy link

soltysh commented Nov 28, 2022

@voidus @jmaupetit any chance to get this in?

@voidus
Copy link
Author

voidus commented Nov 28, 2022

I also added this patch to https://github.com/nixos/nixpkgs so I have it installed cleanly, so I'm not in a personal rush but I'm very much up to working in any requested changes.

They changed the api and the were still calling the functions using
the old api style.

Sadly, the new api doesnt make it easy to test. I have tried for a while
but couldnt get anywhere, so now I tested it manually.
@voidus
Copy link
Author

voidus commented Nov 28, 2022

Rebased on main, no change was needed

@soltysh
Copy link

soltysh commented Nov 28, 2022

I've just downloaded this locally and it looks like it's fixing the problems described in #477.

@sluedecke
Copy link

Works fine (and finally again) for me. Completions are hard, but very useful to me. Please include in upstream!

@Igetin
Copy link

Igetin commented Dec 7, 2022

@jmaupetit Any chance to review and merge this in?

@voidus
Copy link
Author

voidus commented Dec 8, 2022

If jmaupetit isn't available, maybe @willdurand could you have a look? This seems to affect multiple people.

@amsesk
Copy link

amsesk commented Jan 17, 2023

I will add myself to the list of affected people who would like to see this merged. Happy New Year!

@ivan-volnov
Copy link

ivan-volnov commented Mar 27, 2023

@voidus Thank you very much! Used your version of watson.zsh-completion and the completion is working again!

Please finish the PR.

UPD: Works with errors. But works. Waiting for this PR

@voidus
Copy link
Author

voidus commented Apr 23, 2023

FYI, I've stopped using watson. I'd still be happy to tweak this PR if it needs additional work but I won't push for it to be merged.

@Igetin
Copy link

Igetin commented Apr 23, 2023

I’ve been using this branch directly, since it isn’t merged into master yet. I’ve done this for months now and noticed no problems with it.

FYI, I've stopped using watson. I'd still be happy to tweak this PR if it needs additional work but I won't push for it to be merged.

Off-topic, but I’m curious: did you switch to some other tool for time tracking? Watson does its job, but I’d rather use something that is actually maintained.

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

Successfully merging this pull request may close these issues.

None yet

7 participants