-
Notifications
You must be signed in to change notification settings - Fork 3.1k
12446 - better error msg for missing METADATA file #13402
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
@@ -82,6 +82,8 @@ def get_dist_canonical_name(dist: importlib.metadata.Distribution) -> Normalized | |||
return canonicalize_name(name) | |||
|
|||
name = cast(Any, dist).name | |||
if name is None: | |||
raise BadMetadata(dist, reason="missing `METADATA` file") |
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.
We don't only get name
equal to None
when there's a missing METADATA
file, we also get it when the .dist-info
directory's name is incorrect - i.e., not in the form {name}-{version}.dist-info
. There's also the possibility of a failure in get_info_location
that isn't a missing METADATA
file, as well as a .egg-info
file with no stem (although that possibility seems very unlikely to me)
If we want to give a more informative message, we'll need to somehow distinguish the various possible failure cases in parse_name_and_version_from_info_directory
.
tests/functional/test_list.py
Outdated
METADATA file. | ||
""" | ||
# Create a .dist-info dir without METADATA file | ||
dist_info_path = script.site_packages_path / "foo.dist-info" |
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.
This is an invalid .dist-info
file - it should be something like foo-1.0.dist-info
. The name you give will fail, not because of a missing METADATA
file, but because the directory name format is wrong...
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.
Fixed.
METADATA file. | ||
""" | ||
# Create a .dist-info dir without METADATA file | ||
dist_info_path = script.site_packages_path / "foo-1.0.dist-info" |
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.
The bug report shows a reproducer that is missing the version and I can't reproduce this EXCEPT with an invalid .dist-info name. I think the initial bug report is in error. I will comment on the ticket itself.
Closes #12446
Adds a clear error message for when a package is skipped because the METADATA file is missing.