Add stubs for "netiface" package
Hi.
I generated stub files for the netifaces library.
Unfortunately, this library is no longer maintained (although still working well). For this reason, I would like to submit type hints to typeshed.
I compared to the types created initially by @jolaf in https://github.com/al45tair/netifaces/issues/39 and it seems to match well.
PR updated with improved types contributed by @J-M0 here: https://github.com/al45tair/netifaces/pull/77
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
Thanks, good idea!!
Hey all,
It so happens that I actually revisited these stubs I made a while ago and made some significant improvements, but never published them because I didn't think there was any interest. Is there any way we can integrate them into this?
Thanks @J-M0! There's a couple of approaches:
- We could merge this PR, then you could make another PR with your improvements.
- You could make a PR to @Delgan's fork with your changes, to get them merged into this PR branch.
- You could open your own PR against typeshed and replace this one.
If the changes you're making are mostly about expanding the coverage (e.g., adding more types), then I'd advocate for the first one; it's good to start with simpler stubs and make them more comprehensive over time. If you're fixing incorrect types, then it's better to get them right the first time.
@JelleZijlstra, the work I've done is mostly about making the return type for the gateways() function more precise. I also today incorporated @srittau's suggestion to mark constants as Final.
I've pushed my changes here so you can see them: https://github.com/J-M0/netifaces/blob/5dc562a0083b2a24f4fba33257a9b1aa654a3782/netifaces-stubs/init.pyi. Let me know how you think we should proceed.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
Hey @J-M0, thanks for chiming in with additional improvements!
I updated my PR to use PEP 585 and add Final as requested by @srittau.
Your implementation of _Gateways looks very interesting. I was wondering how to encode the invariant of the "default" key, but I didn't think the type system could support it.
@srittau How long would it take for the changes to become available as types-netifaces in pip?
Packages are built nightly (UTC time).