Skip to content

Abstract methods in non-abstract imporlib.metadata.Distribution #419

Closed
@busywhitespace

Description

@busywhitespace

The empty methods read_text and locatate_file of Distribution class are decorated with abc.abstractmethod. But Distribution class doesn't have metaclass=abc.ABCMeta.

PEP 3119, Introducing Abstract Base Classes, states.:

The abstractmethod decorator should only be used inside a class body, and only for classes whose metaclass is (derived from) ABCMeta.

Considering the facts that methods read_text and locate_file are used in other methods of Distribution class and both are empty, only things containing are docstrings, I think the author of the class intended to use the abstractmethod functionality to enforce an implementation of the aforementioned methods. So, in my opinion, the Distribution class should have metaclass=abc.ABCMeta.

(Other possibility is that the aforementioned methods are intended as stubs. Then the abstractmethod decorator may be deleted.)

I've created the PR in case the issue is right, i.e. the class should contain metaclass=abc.ABCMeta.

Linked PRs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions