Skip to content

Conversation

@marsfan
Copy link
Contributor

@marsfan marsfan commented Nov 13, 2025

Back in 2017, #1080 added in TypeVar to handle correctly indicating how the arguments for select.select were passed through to the return values. But unfortunately it caused issues for when an empty Iterator was provided for an argument, as mypy could not resolve the type, so it was reverted in #1097

But now, TypeVar has an optional default argument that is used to set a default when the type is not provided, and we have the Never type to indicate a case where there is an empty list. By combining the two , it is now possible to support more descriptive types.

Signed-off-by: Gabe R. <lockheedmaniac@gmail.com>
@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks! It might be safer (for gradual typing) to use a default of Any, but since there are no primer hits, we can try this variant first, and still "downgrade" to Any if it causes problems.

@srittau srittau merged commit c453da9 into python:main Nov 14, 2025
63 checks passed
@marsfan
Copy link
Contributor Author

marsfan commented Nov 15, 2025

@srittau Sounds like a plan.

I think (but I may be wrong) that if we useAny is that it does not make it as clear that if you pass in an empty array for an argument, then the output array will also be empty, so hopefully Never does not cause any issues.

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