-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add commands overloads from typeshed #5020
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
base: main
Are you sure you want to change the base?
Conversation
aba5b5f to
f15e802
Compare
f15e802 to
b67d72b
Compare
62fb251 to
157f75d
Compare
157f75d to
a723310
Compare
|
Thank you very much for working on this @Avasam. I really appreciate the effort and the direction that you plan to move the codebase. So I wanted to give you some feedback. Before proceeding with the review/merge, I would like to hear @jaraco, mostly because this PR introduces a large amount of typing‑related boilerplate. I'm a bit unsure about this level of case‑by‑case expansion. I don't know if it is something we can sustainably maintain in the code-base. Patterns like case-by-case analysis which require importing every submodule individually and then writing an exhaustive set of overloads tend to break the "single source of truth" principle, and introduce code prone to be brittle. That's my main hesitation, not the idea/intention itself, but the long‑term impact on the codebase. Ideally, I'd really like to find a solution that gives us better typing coverage without requiring such extensive double/triple bookkeeping. |
|
It's unfortunate that the Python typing ecosystem doesn't allow dynamically / programmatically generated types (like typescript does where you can do string manipulation to match a type/attribute name and it'll resolve to that type). And I don't think we're gonna get anything close for a long time ^^" I agree this looks like a lot, but I still want to offer it as it is the most correct result to prevent both false-positives and false-negatives in user code. Trying to make a case for it.
Trying to find potential alternatives that are still improvements on the satus-quo / closer to what typeshed does:
This also differs from #5021 and #5022 where TypedDicts improvements can likely now allow a more DRY approach. |
Summary of changes
Adds the Command-related overloads from typeshed.
This makes it so that
castis no longer necessary when using those methods.Only non-deprecated commands that setuptools exposes directly are listed (so nothing that requires importing from distutils directly, and excludes the
testcommand). Private commands are still listed due to setuptools itself using them.Works towards #2345
Pull Request Checklist
newsfragments/. (not public facing untilpy.typedmarker is added)(See documentation for details)