-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[FR] Vendor distutils stubs #4689
Comments
Thank you very much @Avasam for having a look on this. I will leave the final call on this to Jason. But my first impression is that this is a bit too intrusive to be handled in this repo. (We don't even maintain Now, the approach in #4704 is better, but it still introduces a lot of noise and some level of extra maintenance. It would be nice if I wonder if there would be another approach... Let's assume that we all are willing to move (Moving |
I agree that in the form of #4691, setuptools isn't the place to host these stubs. It is however, the best place for a PR to show the effects. (which probably means I should mark it as draft). #4704 is different though, as setuptools is responsible for the distutils hack. I think that from a separation of concerns pov, pypa/distutils shouldn't need to be aware that setuptools implements it using import hacks nor the exact folder name it lives in. In other words, setuptools is responsible for the distutils hack, and it should be responsible for the stub aliasing In the hypothetical that For the sake of completeness, I'll also mention that pypa/distutils could also generate stubs from inline types that would exist in the pypa/distutils repo, get vendored and distributed by setuptools. In all cases, setuptools should in the long term* be responsible to ship * As long as |
What's the problem this feature will solve?
Type-checkers don't see distutils as available in Python 3.12+
This is already causing us much pain when it comes to type-checking, and is becoming a blocker.
One of the main issue is that importing from distutils, types are seen as
Any
, which breaks subclassing, removes tons of type-safety, and creates nasty inconsistencies when trying to type-check <3.12 vs >=3.12.We also get some overriding issues when type-checkers don't understand we're using an updated distutils version vendored from pypa/distutils.
As long as
_distutils_hack
exists, we can't have type-checkers scan the vendored version instead. (if pypa/distutils was installed like a regular package, this wouldn't be an issue either)Describe the solution you'd like
My suggestion is to vendor
distutils-stubs
, reflecting the types as the modernized pypa/distutils.(concretely this means: Start with https://github.com/python/typeshed/tree/main/stdlib/distutils, then apply https://github.com/python/typeshed/tree/main/stubs/setuptools/distutils on top)
Those stubs should exist in the repo in a folder named
distutils
ordistutils-stubs
.distutils-stubs
should be installed in users' site-packages when installingsetuptools
(this can be locked behind an extra if you have concerns for vendors)This also means we no longer need to wait on new mypy releases to get distutils typing fixes from typeshed AND we can be more accurate to what
_distutils
does.Alternative Solutions
._distutils
in setuptools instead.Additional context
Code of Conduct
The text was updated successfully, but these errors were encountered: