Skip to content

.metadata is an empty message even for missing metadata #493

@jaraco

Description

@jaraco

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions