Skip to content

import.metadata overview missing import statement #142197

Description

@lubianat

Documentation

Going through https://docs.python.org/3/library/importlib.metadata.html#overview I was following

You can get the :ref:`metadata for a distribution <metadata>`::
>>> list(metadata('wheel')) # doctest: +SKIP
['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'Maintainer', 'Maintainer-email', 'License', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Provides-Extra', 'Requires-Dist', 'Requires-Dist']

and got as a result

>>> list(metadata('wheel'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'metadata' is not defined
>>> from importlib.metadata import metadata
>>> list(metadata('wheel'))
['Metadata-Version', 'Name', 'Version', 'Summary', 'Keywords', 'Author-email', 'Maintainer-email', 'Requires-Python', 'Description-Content-Type', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Dist', 'Requires-Dist', 'Project-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Provides-Extra', 'Description']

It could make sense to add from importlib.metadata import metadata to the docs.

Cheers,
Tiago

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions