Skip to content

Commit b40c7f0

Browse files
committed
Always include applicable fields in list --json
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.
1 parent e9f4612 commit b40c7f0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

news/7764.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Always include fields ``installer`` and ``location`` in ``pip list --json``
2+
output regardless of verbosity.

src/pip/_internal/commands/list.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,10 @@ def format_for_json(packages, options):
301301
for dist in packages:
302302
info = {
303303
'name': dist.project_name,
304+
'installer': get_installer(dist),
305+
'location': dist.location,
304306
'version': six.text_type(dist.version),
305307
}
306-
if options.verbose >= 1:
307-
info['location'] = dist.location
308-
info['installer'] = get_installer(dist)
309308
if options.outdated:
310309
info['latest_version'] = six.text_type(dist.latest_version)
311310
info['latest_filetype'] = dist.latest_filetype

0 commit comments

Comments
 (0)