-
-
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
Generate distutils-stubs
on install
#4861
base: main
Are you sure you want to change the base?
Conversation
Aaaah, right, I forgot that Overall still an improvement (and typeshed won't have to special case this stub anymore) and a necessary step for #2345 |
module = "setuptools._distutils." + str(relative_path.with_suffix("")).replace( | ||
os.sep, "." | ||
).removesuffix(".__init__") |
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.
Alternative code for readability (but less "correct" because replace
is run on an unnecessary extra bit of str
):
module = "setuptools._distutils." + str(relative_path.with_suffix("")).replace( | |
os.sep, "." | |
).removesuffix(".__init__") | |
module = ( | |
("setuptools._distutils." + str(relative_path.with_suffix(""))) | |
.replace(os.sep, ".") | |
.removesuffix(".__init__") | |
) |
Playing with it some more (also changed with_suffix
for removesuffix
, just to see):
module = "setuptools._distutils." + str(relative_path.with_suffix("")).replace( | |
os.sep, "." | |
).removesuffix(".__init__") | |
module = ( | |
"setuptools._distutils." # (don't unwrap) | |
+ str(relative_path) | |
.removesuffix(".py") | |
.replace(os.sep, ".") | |
.removesuffix(".__init__") | |
) |
Summary of changes
3rd iteration to close #4689 (doesn't solve everything mentioned in that issue, but it would greatly reduce the scope so I'd prefer re-opening as a new issue)
This is built off of #4704 where the stubs are automatically generated, but now they're done on install instead of existing in the source code.
Further Advantages over #4704:
Further Disadvantages over #4704:
pip install .
) to get proper type-checking in their editor on Python 3.12+ when it comes to pypa/distutils derived types. (they already had to installtypes-setuptools
, this replaces that)Pull Request Checklist
newsfragments/
.(See documentation for details)