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

consolidate vcs link detection #6883

Merged
merged 1 commit into from
Aug 16, 2019
Merged

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Aug 15, 2019

While working on #6853 and #6851, it was not immediately obvious to me why not link.is_artifact means it is a VCS link.

So I thought I could make this little readability improvement, by replacing the global is_vcs_url function by a is_vcs property of Link.

Copy link
Member

@cjerdonek cjerdonek left a comment

Choose a reason for hiding this comment

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

This looks like a good simplification. Thanks!

def is_vcs(self):
from pip._internal.vcs import vcs

return self.scheme in vcs.all_schemes
Copy link
Member

Choose a reason for hiding this comment

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

Since with this change this logic is getting duplicated in both is_vcs and is_artifact, I think it would be best if is_artifact is changed to call this method. (And you can move is_vcs before is_artifact so is_artifact is depending on methods defined before it.) Also, that way we avoid introducing a second nested import.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Done.

@chrahunt
Copy link
Member

Looks good to me.

from pip._internal.vcs import vcs

if self.scheme in vcs.all_schemes:
if self.is_vcs:
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this can just be:

return not self.is_vcs

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes of course, but reading the docstring I had the feeling it was meant to evolve to cover other cases. That is also the reason I refrained of implementing is_vcs as not is_artifact. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

It's always possible things can change in the future, but we can cross that bridge when we get to it! :)

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I do agree the current docstring is confusing..

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, done and squashed.

Copy link
Member

Choose a reason for hiding this comment

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

Great! 👍

@cjerdonek cjerdonek merged commit 76ae377 into pypa:master Aug 16, 2019
@sbidoul sbidoul deleted the is_vcs-refactor-sbi branch August 16, 2019 08:21
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Sep 15, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 15, 2019
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants