-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Column formatting for "pip list" #3654
Conversation
Whoops, I forgot unit tests. Working on those now. As for the failing travis-ci tests:
|
I'll continue fixing the unit test failures tomorrow. Need to figure out (I'm talking to myself here; respond if you'd like but don't feel like it's necessary):
|
for dist, latest_version, typ in sorted( | ||
self.find_packages_latest_versions(options), | ||
key=lambda p: p[0].project_name.lower()): | ||
if latest_version > dist.parsed_version: | ||
latest_pkgs.append((dist, latest_version, typ)) | ||
|
||
if (hasattr(options, "columns") and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of the logic in this block, but it works. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm comfortable with "get it working first, tidy up later". So don't worry about it for now.
Alrighty, all tests are finally passing. Couple of questions:
|
@@ -53,7 +58,7 @@ def __init__(self, *args, **kw): | |||
help=('If in a virtualenv that has global access, do not list ' | |||
'globally-installed packages.'), | |||
) | |||
self.cmd_opts.add_option( | |||
cmd_opts.add_option( | |||
'--user', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unrelated bug-fix? If so, could you split it out into a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I'm aware of. I must have removed it during one of my "let's clean things up" sprees. I noticed that this had self
while others didn't. I'll revert it.
Overall, looking good. I added some review comments. The one big one is that you seem to be generating the To answer your questions:
|
I think you should be able to figure out the warning by just having three states on the same variable like this: # TODO: When we switch the default, set default=True here and then
# adjust pip/commands/list.pip to remove ``and options.columns is None``.
columns = partial(Option, "--columns", dest="columns", action="store_true")
no_columns = partial(Option, "--no-columns", dest="columns", action="store_false") I think this should work in such a way that if someone specifies # TODO: Remove the ``and options.columns is None`` when we switch
# the default.
if not options.columns and options.columns is None:
warnings.warn(...) |
Yes, that's what was happening. I guess I misunderstood @dstufft request in #3651 - it sounded like you wanted the deprecation warning in the implicit case. Alrighty, cool. Thanks for the feedback. I'll be able to run these changes through on Monday (GMT-8). |
|
||
:: | ||
|
||
$ pip list --columns --no-header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--no-header
is no longer a valid option (was replaced with --no-columns
)
As a check point, needs an item in the changelog |
Alrighty, I think we're good to go again.
Let me know if I'm missing anything. |
Hey, this looks pretty good to me and I'd be happy to merge it, but It appears it has merge conflicts. If you get the time to fix that i can merge it then or I'll try to pull it down and rebase it myself. Whichever you prefer. Thanks a lot! |
Agreed this is looking good. Thanks @dougthor42 for doing this! |
I like it also but would be more in favor of a |
Once the deprecation process is over |
(and maybe even a |
@xavfernandez I'm inclined to wait until someone actually implements a JSON or freeze format and at that point, add a Let's keep this PR focused on the one improvement for now. |
@pfmoore Agreed. |
Looking forward to it :-) |
Looks like the conflict was simply with |
Great! Will merge once tests pass again and the status is green. Thanks a lot :) |
'pip list' formatting has changed, and it shows a deprecation warning if we don't set the --format option: pypa/pip#3654
Summary
This PR adds optional column formatting to
pip list
via the commands--columns
and--no-header
.Fixes #3651.
Discussion
There is a lot of looping going on to accomplish this PR. I don't think it's a big deal because the list of installed packages is rarely large enough that having multiple loops would cause a significant slowdown. Where reasonable (for speed and readability), I've used list comprehensions instead.
While the call signature of
output_package_listing
was changed, it was not changed in a way that would effect other calls since the newoptions
argument defaults toNone
.If
output_package_listing
is called withoptions=None
then there is no change to the previous behavior.Examples
Standard output of
pip list
is not changed. New output looks like so:This change is