Skip to content
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

Statically alias distutils-stubs to setuptools._distutils #4704

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Oct 25, 2024

Summary of changes

Closes #4689
This is an alternative to #4691. This makes type-checkers and editors see distutils as basically an alias to setuptools.

Advantage:

  • Less maintenance work, these stubs can be autogenerated when updating the vendored stubs (if a file is removed or added)
  • No need to keep in sync with typeshed
  • Static typing follows directly pypa/distutils without concerns with stdlib/distutils compatibility

Disadvantage:

  • Typing isn't as good or as complete as typeshed's
  • Typing improvements and fixes need to be done "in source" in pypa/distutils. But this is somewhat already the long-term plan (Add type hints to setuptools #2345 (comment) but directly in pypa/distutils)
  • pypa/distutils could accidentally introduce a typing breaking change for setuptools, which probably needs to be ignored with a TODO when updating the vendor.

Pull Request Checklist

  • Changes have tests (existing type-checking tests)
  • News fragment added in newsfragments/. (no need until this is shipped with setuptools)
    (See documentation for details)

@@ -228,7 +223,7 @@ def reinitialize_command(
) -> _Command:
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
vars(cmd).update(kw)
return cmd
return cmd # pyright: ignore[reportReturnType] # pypa/distutils#307
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Avasam Avasam force-pushed the statically-alias-distutils-stubs-to-setuptools._distutils branch 5 times, most recently from 1733d12 to f950ecc Compare October 25, 2024 20:33
@abravalheri abravalheri mentioned this pull request Oct 25, 2024
1 task
@Avasam Avasam force-pushed the statically-alias-distutils-stubs-to-setuptools._distutils branch 3 times, most recently from 47321db to 7085815 Compare November 20, 2024 21:13
@Avasam Avasam force-pushed the statically-alias-distutils-stubs-to-setuptools._distutils branch from 7085815 to e66c7ae Compare November 24, 2024 22:53
@Avasam
Copy link
Contributor Author

Avasam commented Nov 25, 2024

I've added a comment at the top of geenrated files to make it clear that they are generated and how to regenerate them.

Comment on lines +183 to +184
] + install.new_commands # type: ignore[operator]
# TODO: Type sub_commands/new_commands to avoid variance issues in pypa/distutils (like python/typeshed#11951)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -53 to +58
negative_opt: ClassVar[dict[str, str]] = {}
# TODO: Mark class-level mutables as ClassVars in pypa/distutils (like python/typeshed#12403)
negative_opt: ClassVar[dict[str, str]] = {} # type: ignore[misc]

README_EXTENSIONS = ['', '.rst', '.txt', '.md']
READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS)
# TODO: Mark some class-level tuples as as not fixed-length pypa/distutils (like python/typeshed#12403)
READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS) # type: ignore[assignment]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Vendor distutils stubs
1 participant