Skip to content

Conversation

@Avasam
Copy link
Collaborator

@Avasam Avasam commented Dec 21, 2025

Resolves #15146 (comment) introduced in that same PR.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

@srittau srittau merged commit 7dea899 into python:main Dec 22, 2025
48 checks passed
@Avasam Avasam deleted the setuptools.setup-Command-type-variance-issue branch December 22, 2025 15:50
@henryiii
Copy link
Contributor

Hopefully this fixes the issue with setuptools.setup now returning Any in 80.9.0.20251221. (Seen in scikit-build/scikit-build-core#1198)

@srittau
Copy link
Collaborator

srittau commented Dec 22, 2025

I don't think it will fix the return type. We might need an overload for the case where distclass is not defined, although the type var has a default. Cc @Avasam

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 22, 2025

Ugh, doing an overload here will be annoying, but maybe I'll have to. I don't think I can even use non-closed TypedDict unpacking (from https://peps.python.org/pep-0728/) here.

I wonder why pyright and pyrefly infer correctly but neither mypy nor ty does.
Edit: I somehow misread, mypy is clearly shown to be giving the correct return type in my screenshot.
The TypeVar is bound and has a default, I fully expected the return type to have a known lower-bound.
image

I think pyright takes into account the default assignement whereas the other two don't
image
image

@srittau
Copy link
Collaborator

srittau commented Dec 22, 2025

Yes, it seems to me that the type checkers should use the default here.

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 22, 2025

Idk how I managed to misread it and post a screenshots. But actually isn't it showing that the return type isn't Any on mypy if omitting distclass ?

I just checked https://github.com/scikit-build/scikit-build-core/blob/main/src/scikit_build_core/setuptools/wrapper.py and the issue there is that **kw: Any explicitly, so the inferred distclass is also Any, so checkers infer Any as the return type.

@henryiii Making scikit_build_core.setuptools.wrapper.setup's return type generic based on distclass like we're doing here would fix your no-any-return and make it more accurate to runtime.

So I think that's actually a true positive.

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.

3 participants