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

Use correct executable name for completion command #4755

Merged
merged 6 commits into from Oct 12, 2017
Merged

Conversation

di
Copy link
Sponsor Member

@di di commented Oct 2, 2017

Fixes #3997.
Closes #4014.

@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Oct 2, 2017
@di
Copy link
Sponsor Member Author

di commented Oct 2, 2017

Oops, I missed that there was an open PR for this. 🙁

For what it's worth, I think this approach is better, because it a) reuses an existing utility function b) fixes a bug in said utility function and c) adds tests.

@pradyunsg
Copy link
Member

I think this approach is better

I agree.

PS: I modified the OP to also close the other PR.

@@ -80,7 +83,9 @@ def run(self, options, args):
shell_options = ['--' + shell for shell in sorted(shells)]
if options.shell in shells:
script = textwrap.dedent(
COMPLETION_SCRIPTS.get(options.shell, '')
COMPLETION_SCRIPTS.get(options.shell, '').format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just simply do a % formatting; for consistency?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

""",
'fish': """
function __fish_complete_pip
set -lx COMP_WORDS (commandline -o) ""
set -lx COMP_CWORD {cword}
set -lx COMP_CWORD ( \\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out that this line changed and I've not verified that this change works; I'm pretty sure it would but yeah.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified that this still works (I also learned that fish shell is pretty nice!). I changed this line because the .format was unnecessary, but these lines still need to be < 80 characters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'd added the .format as a hack for making the lines < 80 characters in #4509. I intended to come around to it whenever I would have found the time to fiddle around with fish -- a duration long enough to do it justice anyway. :P

I also learned that fish shell is pretty nice!

It is indeed.

@floam
Copy link

floam commented Oct 5, 2017

FYI, we've just merged in pip completions using pip's completion mechanism on the fish project, (fish-shell/fish-shell#4448) and ran into what this PR will fix. Happy to see it's in the works!

@floam
Copy link

floam commented Oct 5, 2017

(Any idea why it's so slow to output anything?

$ pip2 completion --fish > /dev/null
$ echo $CMD_DURATION
636

... it causes some lag when tab completing.)

@pradyunsg
Copy link
Member

Hi @floam!

I'd speculate that is mostly startup time for pip and Python combined? The latter is something a lot of people are working on right now and the former is indeed something that I'm planning to look into eventually.

@floam
Copy link

floam commented Oct 5, 2017

Hm, maybe 35ms is Python starting up itself, the other 600ms appears to occur in pip. Anyhow, off topic for this PR, sorry!

mqudsi added a commit to fish-shell/fish-shell that referenced this pull request Oct 5, 2017
Work around bug pypa/pip#4755
Don't expect all users to be running a version of pip2/3 that includes
the fix (once it's upstreamed). Will continue to work if/when pip2/3
emit the correct output. pip is already very slow at printing the
completions (see #4448) so the `sed` call overhead is neglible.
mqudsi added a commit to fish-shell/fish-shell that referenced this pull request Oct 5, 2017
Work around bug pypa/pip#4755
Don't expect all users to be running a version of pip2/3 that includes
the fix (once it's upstreamed). Will continue to work if/when pip2/3
emit the correct output. pip is already very slow at printing the
completions (see #4448) so the `sed` call overhead is neglible.
@di
Copy link
Sponsor Member Author

di commented Oct 5, 2017

@floam I also noticed this was slow when testing it -- I'd suggest you make a separate issue so it can be addressed.

@pradyunsg
Copy link
Member

@di I think there is one for it...

@xavfernandez
Copy link
Member

There was #3360

@pradyunsg
Copy link
Member

pradyunsg commented Oct 5, 2017

Thanks @xavfernandez! ^.^

I guess, in that case, I'll make a new issue then. (edit: #4768)

@pradyunsg
Copy link
Member

This LGTM. Could another @pypa/pip-committers take a look?

@pradyunsg pradyunsg requested a review from a team October 11, 2017 07:22
@xavfernandez xavfernandez added this to the 10.0 milestone Oct 11, 2017
@pradyunsg
Copy link
Member

Thanks @xavfernandez!

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip3 completion
4 participants