Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@GianlucaFicarelli
Copy link
Contributor

Closes #692.

import importlib_metadata as metadata
elif sys.version_info < (3, 9, 10) or (3, 10, 0) <= sys.version_info < (3, 10, 2):
if sys.version_info >= (3, 10, 2):
from importlib import metadata # type: ignore[attr-defined]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type: ignore workaround is needed to pass the "type" job https://github.com/pypa/build/actions/runs/6558894339/job/17813388696?pr=693
I didn't find a better way 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

if sys.version_info < (3, 8):
    import importlib_metadata as metadata
elif sys.version_info >= (3, 10, 2):
    from importlib import metadata
else:
    try:
        import importlib_metadata as metadata
    except ModuleNotFoundError:
        # helps bootstrapping when dependencies aren't installed
        from importlib import metadata

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this worked, thanks (side note, I'm surprised that mypy still raises an error when the the order of the first two conditions is inverted)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

project_wheel_metadata returns email.message.Message instead of importlib.metadata._adapters.Message in python 3.9

2 participants