Skip to content

importlib does not export a version atribute in the EntryPoint class #72

Description

@pedrohc

$ click-man cve
Traceback (most recent call last):
File "[...]/cvelib/.venv/bin/click-man", line 10, in
sys.exit(cli())
~~~^^
File "[...]/cvelib/.venv/lib64/python3.13/site-packages/click/core.py", line 1442, in call
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "[...]/cvelib/.venv/lib64/python3.13/site-packages/click/core.py", line 1363, in main
rv = self.invoke(ctx)
File "[...]/cvelib/.venv/lib64/python3.13/site-packages/click/core.py", line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]/cvelib/.venv/lib64/python3.13/site-packages/click/core.py", line 794, in invoke
return callback(*args, **kwargs)
File "[...]/cvelib/.venv/lib64/python3.13/site-packages/click_man/shell.py", line 80, in cli
man_version = entry_point.version
^^^^^^^^^^^^^^^^^^^
AttributeError: 'EntryPoint' object has no attribute 'version'

My pyproject.toml:

[project.scripts]
cve = "cvelib.cli:cli"

The EntryPoints class does not have a version attribute:
https://github.com/python/cpython/blob/6260b6ae24e11b3d338c72f0391de442756e33ca/Lib/importlib/metadata/__init__.py#L250

This bug was probably introduced here:
b1c4695

Workaround is to explicitly call the --man-version option.

Option for a fix is to use the importlib.metadata.version() function instead:
https://github.com/python/cpython/blob/1bbf7b661f0ac8aac12d5531928d9a85c98ec1a9/Lib/importlib/metadata/__init__.py#L357

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions