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

pip list --not-required --outdated should list only outdated packages… #6116

Merged
merged 2 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5737.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`pip list --outdated --not-required` should list only outdated packages that are not dependencies of installed packages
10 changes: 7 additions & 3 deletions src/pip/_internal/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ def run(self, options, args):
include_editables=options.include_editable,
)

# get_not_required must be called firstly in order to find and
# filter out all dependencies correctly. Otherwise a package
# can't be identified as requirement because some parent packages
# could be filtered out before.
if options.not_required:
packages = self.get_not_required(packages, options)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment explaining why this should stay before the other filter operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for comments. The explanation added.


if options.outdated:
packages = self.get_outdated(packages, options)
elif options.uptodate:
packages = self.get_uptodate(packages, options)

if options.not_required:
packages = self.get_not_required(packages, options)

self.output_package_listing(packages, options)

def get_outdated(self, packages, options):
Expand Down
15 changes: 15 additions & 0 deletions tests/functional/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,21 @@ def test_outdated_editables_columns_flag(script, data):
)


def test_outdated_not_required_flag(script, data):
"""
test the behavior of --outdated --not-required flag in the list command
"""
script.pip(
'install', '-f', data.find_links, '--no-index',
'simple==2.0', 'require_simple==1.0'
)
result = script.pip(
'list', '-f', data.find_links, '--no-index', '--outdated',
'--not-required', '--format=json',
)
assert [] == json.loads(result.stdout)


def test_outdated_pre(script, data):
script.pip('install', '-f', data.find_links, '--no-index', 'simple==1.0')

Expand Down