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

unexpected Incompatible types when using Union type in list #18201

Closed
MatthieuCMira opened this issue Nov 27, 2024 · 1 comment
Closed

unexpected Incompatible types when using Union type in list #18201

MatthieuCMira opened this issue Nov 27, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@MatthieuCMira
Copy link

MatthieuCMira commented Nov 27, 2024

consider a utility function:

from __future__ import annotations
from uuid import UUID

def utility_function(data: list[str | UUID] | None):
     pass

If I'm using it in this context, mypy complains:

def other_function(data: list[str]):
    utility_function(data)

raises:

error: Argument "data" to "utility_function" has incompatible type "list[str]"; expected "list[UUID | str] | None" [arg-type]
`

This kind of data dependency should be accepted no?

mypy version: 1.13.0

@MatthieuCMira MatthieuCMira added the bug mypy got something wrong label Nov 27, 2024
@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants