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

Record on the requirement whether it has been successfully downloaded #7710

Merged
merged 1 commit into from
Feb 8, 2020

Conversation

pfmoore
Copy link
Member

@pfmoore pfmoore commented Feb 7, 2020

This moves the information about whether a requirement has been successfully downloaded out of the requirement set and onto the requirement itself.

The code that determines whether a requirement has been "successfully downloaded" is in the resolver, so this initial refactoring doesn't reduce the coupling between the resolver and the client code (the pip download command) very much. However, it does move the information the client needs from the RequirementSet (which we're trying to mke into an implementation detail of the resolver) to the requirement itself (which is what logically owns the information).

A subsequent PR could then put the responsibility for determining when the requirement has been successfully downloaded onto the requirement itself.

@pfmoore pfmoore added the skip news Does not need a NEWS file entry (eg: trivial changes) label Feb 7, 2020
@pfmoore pfmoore requested a review from pradyunsg February 7, 2020 17:07
@@ -133,7 +133,8 @@ def run(self, options, args):
)

downloaded = ' '.join([
req.name for req in requirement_set.successfully_downloaded
req.name for req in requirement_set.requirements.values()
if req.successfully_downloaded
Copy link
Member

Choose a reason for hiding this comment

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

Q: does changing this to the following work?

Suggested change
if req.successfully_downloaded
if not req.editable and not req.satisfied_by

Copy link
Member

Choose a reason for hiding this comment

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

If it does... we could just drop the attribute basically.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll give it a try. But even if it does work I think I'd want to hide it behind a successfully_downloaded() method, because that expression gives no hint that it's checking if the requirement was downloaded :-(

Then at least the poor soul who looks at that code in the future stands some chance of knowing what's going on!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, the tests work with this change. But I did grep through the tests for "Successfully downloaded", and didn't get any hits, so I'm not actually sure we test for this.

So I'd prefer to stick with the current PR, as it's behaviourally the same as the existing code. We can add a test for the behaviour, and then refactor further, in a follow-up. For now, this decouples the download command from the RequirementSet, which is the important step at the moment.

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

The change does what it says in the title correctly. Separate comment made, which might make this redundant though. :P

Copy link
Member

@chrahunt chrahunt left a comment

Choose a reason for hiding this comment

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

Definitely an improvement!

@chrahunt chrahunt merged commit 8201c42 into pypa:master Feb 8, 2020
@pfmoore pfmoore deleted the successfully_downloaded_refactor branch February 8, 2020 12:43
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Mar 10, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
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 skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants