Skip to content

Encourage use of importlib.metadata.version #15671

@jakkdl

Description

@jakkdl

Description

I only recently found out about importlib.metadata.version as a way of getting the installed version of a package; as opposed to reading some global __version__ variable that may or may not be properly exported.
I would love a rule that encouraged the use of the more portable & reliable importlib variant, although I have a feeling that a simple rule that detected any from ... import __version__ would raise a bunch of false alarms on packages that export it as ways of versioning ... other things than the package itself. (maybe only trigger if importing from the top namespace of a module?) Or idk other weird stuff.

Anyway, thought I'd throw out the idea anyway and see if it sticks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions