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

Add remaining types to setuptools.build_meta #9890

Merged
merged 4 commits into from
Mar 16, 2023

Conversation

henryiii
Copy link
Contributor

This is an attempt to finish the incomplete types in setuptools.build_meta. This is really useful if you are "wrapping" the PEP 715 interface to add something (like a dynamic dependency.

Also adds the missing editable hooks (PEP 660), added in setuptools 62 IIRC.

Original source: https://github.com/pypa/setuptools/blob/main/setuptools/build_meta.py

Example of usage (currently full of type ignores): https://github.com/scikit-build/scikit-build-core/blob/main/src/scikit_build_core/setuptools/build_meta.py

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@github-actions

This comment has been minimized.

@henryiii
Copy link
Contributor Author

henryiii commented Mar 15, 2023

Any idea how I can test this with a local copy of mypy? Mypy seems to refuse to use the typeshed stubs even if I add --custom-typeshed-dir, it it seems to produce Skipping analyzing "setuptools.build_meta": module is installed, but missing library stubs or py.typed marker (also the other subdirs) if I add it to the MYPYPATH. Edit: realized it's in a setuptools subdirectory.

@henryiii henryiii marked this pull request as ready for review March 15, 2023 19:36
@henryiii
Copy link
Contributor Author

Not a complete test of the API, but I was able to remove my type ignores and it's passing!

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Looks good! The stubs for the global functions can be simplified a bit, see my comment below.

For some of the parameters currently annotated with str, they will strictly speaking also accept os.PathLike objects, since the arguments are immediately passed to os.path.abspath, which accepts path-like objects. But the fact that these parameters accept path-like objects now seems like an accident of the current implementation, rather than something that's designed to be supported. So let's stick with your current annotation of str for those parameters.

stubs/setuptools/setuptools/build_meta.pyi Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit eb3f8f3 into python:main Mar 16, 2023
@henryiii henryiii deleted the henryiii/fix/setuptoolsbuildmeta branch March 16, 2023 18:24
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.

2 participants