-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 718: More rationale, use-cases and expansion on monomorphisation #3631
Conversation
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
||
def foo[T](x: Sequence[T] | T) -> list[T]: ... | ||
|
||
reveal_type(foo[bytes](b"hello")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is maybe a better fit for the discussion, but I find this example disturbing, because it seems I could also write foo[int](b"hello")
, match the Sequence
part of the Union, and now the type checker would infer that the function returns list[bytes]
instead of list[int]
. Isn't that inherently unsound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I do see your point here but isn't the current situation still unsound because the choosing of the type from the type checker is still up to its logic?
PEP 123: Summary of changes
)📚 Documentation preview 📚: https://pep-previews--3631.org.readthedocs.build/