-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix misleading Multiple directories found assertion in _find_info_directory
#5160
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes _find_info_directory so that a “no candidates found” case no longer triggers the misleading Multiple {suffix} directories found assertion, and instead fails with the intended “No {suffix} directory found” error.
Changes:
- Split the prior combined condition into: (1) return when a
{suffix}directory is found, (2) abort the walk early when traversal becomes ambiguous (len(dirs) != 1). - Prevent the incorrect assertion path when
candidatesis empty.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @ooooo-create, thank you very much for the contribution. Could you please fill in an issue report containing the description of the problem you are trying to solve first, with a minimal reproducible example? These checks are somewhat old in the codebase, despite being refactored a bunch of times, this check has always been present in one form or other since the introduction of PEP 517. So I would like to understand a bit better which kinds of problems you may have had. In a different iteration, this piece of code had a different message: |
Thanks for your suggestion. Here is a bash script to reproduce it However, I ran into this issue because I had multiple setup() calls in my setup.py that were triggered by different conditions. I accidentally caused the execution flow to bypass all of them, and realized that the resulting error—AssertionError: Multiple .egg-info directories found—was actually misleading.
yes~ it's better, i will take it. |
|
I see... Thank you very much. Yeah, it is an I think we should go with a better error message and avoid changing too much the code itself. |
Multiple directories found assertionMultiple directories found assertion in _find_info_directory
Summary of changes
If the search failed to find any candidates (len(candidates) == 0) in a directory that had no subdirectories or multiple subdirectories (len(dirs) != 1), the condition evaluated to True. This triggered the assertion checks for candidates == 1, resulting in a confusing AssertionError: Multiple {suffix} directories found, even though zero candidates were actually found.
Closes
Pull Request Checklist
newsfragments/.(See documentation for details)