-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
type annotations #449
type annotations #449
Conversation
FYI, @RonnyPfannschmidt was also considering tackling this effort (discussion in #importlib-metadata channel on PyPA discord). |
Cool. I'm mostly just aiming for the low-hanging fruit here and perhaps testing the waters for receptiveness to further work. The pipeline and I both are currently happy; I reckon I'm done fiddling with this one now. |
I have not yet started own work, great to see this start |
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.
This looks good and nearly ready to merge. Just a few concerns to address.
OK, I've pushed change that - I hope - err in the direction of avoiding and deferring any difficult questions
|
Yes. |
the code that you have merged still used importlib_metadata/importlib_metadata/__init__.py Lines 796 to 798 in 705a757
|
Aah. I was looking at the wrong thing (because it wasn't in the diff). I think |
I realized that the declaration of |
It's kind of annoying that this library publishes a py.typed, but most of the API is not type-annotated. Users who check their own code with mypy are obliged to scatter around
# type: ignore[no-untyped-call]
comments.Possible points of interest:
joinpath
on theSimplePath
seems to have been just wrongIterable
s asIterator
s, because (i) they are and (ii)Distribution.from_name()
relies on this when it callsnext(..)
rather thannext(iter(..))
This MR doesn't annotate the whole API: I've ducked the slightly difficult ones like
distributions()
,select()
andmatches()
. typeshed has annotations that are presumably satisfactory in practice, but it looks as though applying them here would be more invasive than I intend to be in this commit. https://github.com/python/typeshed/blob/main/stdlib/importlib/metadata/__init__.pyiThis MR is a long way from annotating the whole project -
mypy --strict importlib_metadata
reports 171 errors, so it would take a bit more of a campaign to work through that.