Skip to content

Commit

Permalink
Always include applicable fields in list --json
Browse files Browse the repository at this point in the history
Since the JSON output is designed for machine consumption, it does not
make much sense to have the verbosity flag influence its output. This
change makes `installer` and `location` to always be included.
  • Loading branch information
uranusjr committed Feb 25, 2020
1 parent e9f4612 commit b40c7f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions news/7764.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Always include fields ``installer`` and ``location`` in ``pip list --json``
output regardless of verbosity.
5 changes: 2 additions & 3 deletions src/pip/_internal/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,10 @@ def format_for_json(packages, options):
for dist in packages:
info = {
'name': dist.project_name,
'installer': get_installer(dist),
'location': dist.location,
'version': six.text_type(dist.version),
}
if options.verbose >= 1:
info['location'] = dist.location
info['installer'] = get_installer(dist)
if options.outdated:
info['latest_version'] = six.text_type(dist.latest_version)
info['latest_filetype'] = dist.latest_filetype
Expand Down

0 comments on commit b40c7f0

Please sign in to comment.