-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use importlib_metadata for Python < 3.10.2 #693
Conversation
src/build/_importlib.py
Outdated
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] |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
5fd5f44
to
52f11f2
Compare
Closes #692.