-
-
Notifications
You must be signed in to change notification settings - Fork 94
Description
In #489 (comment), I learned that Distribution.metadata will return an empty PackageMetadata even when there is no metadata file present.
Although not part of the recommended operating practice, it seems to be occasional occurrence for an uninstalled package to leave a lingering metadata directory (*.dist-info) with nothing in it. Instead, I would expect dist.metadata to be None when no metadata file is present, and to return an empty PackageMetadata object when a metadata file is present but empty.
It seems the reason this expectation was previously missed is because (a) this case hasn't previously been tested, (b) the typespec indicates that email.message_from_string accepts only a str, and (c) the implementation suppresses the type error (introduced in d390898).
The underlying reason email.message_from_string accepts None is because io.StringIO accepts None and is indistinguishable from io.StringIO('') for reading.