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

PEP 718: More rationale, use-cases and expansion on monomorphisation #3631

Merged
merged 5 commits into from
Feb 17, 2024

Conversation

Gobot1234
Copy link
Contributor

@Gobot1234 Gobot1234 commented Jan 23, 2024

  • Change is either:
    • To a Draft PEP
    • To an Accepted or Final PEP, with Steering Council approval
    • To fix an editorial issue (markup, typo, link, header, etc)
  • PR title prefixed with PEP number (e.g. PEP 123: Summary of changes)

📚 Documentation preview 📚: https://pep-previews--3631.org.readthedocs.build/

peps/pep-0718.rst Outdated Show resolved Hide resolved
peps/pep-0718.rst Outdated Show resolved Hide resolved
peps/pep-0718.rst Outdated Show resolved Hide resolved
peps/pep-0718.rst Outdated Show resolved Hide resolved
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
peps/pep-0718.rst Outdated Show resolved Hide resolved
peps/pep-0718.rst Outdated Show resolved Hide resolved
Gobot1234 and others added 2 commits January 24, 2024 15:01
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"))
Copy link
Member

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?

Copy link
Contributor Author

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?

@JelleZijlstra JelleZijlstra merged commit c6c71c5 into python:main Feb 17, 2024
6 checks passed
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.

None yet

4 participants