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

utils: fix has_leading_dir corner case #5794

Closed
wants to merge 1 commit into from

Conversation

benoit-pierre
Copy link
Member

Handle archives with a single file (something that is used by setuptools' testsuite).

@pradyunsg
Copy link
Member

pradyunsg commented Sep 18, 2018

While we don't really bump into this code else, it'd probably make sense to do this.

@@ -236,6 +236,11 @@ def split_leading_dir(path):
def has_leading_dir(paths):
"""Returns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)"""
if not paths:
return False
Copy link
Member

Choose a reason for hiding this comment

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

If the docstring for this function is correct, it seems this should be True. The reason is that, in logic, this is said to be “vacuously true”: if something is true if it is true “for all” such things, and there are no things, then it is true for all of them (because there are none it needs to be true for). If this return value needs to be False for behavior reasons, the docstring should be clarified to reflect the additional conditions that need to be met.

Copy link
Member

Choose a reason for hiding this comment

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

For example, maybe it should read (assuming this is correct): “return True if there is at least one directory and all paths are properly inside it.”

@benoit-pierre
Copy link
Member Author

Amended.

@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Sep 27, 2018
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Sep 27, 2018
Handle archives with a single file (something that is used by
setuptools testsuite).
@benoit-pierre
Copy link
Member Author

Rebased.

('''
pkg-1.0/
pkg-1.0/
''', True),
Copy link
Member

Choose a reason for hiding this comment

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

Something doesn't seem right about the function implementation since, for example, ["pkg-1.0/", "pkg-1.0/"] returns True but ["pkg-1.0/"] returns False (see further up for a test case for the latter).

@cjerdonek
Copy link
Member

cc @waveform80

@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 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.

5 participants