Skip to content

LiteralString should not be compatible with str in an invariant context #16169

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

Closed
erictraut opened this issue Sep 24, 2023 · 1 comment
Closed
Labels
bug mypy got something wrong

Comments

@erictraut
Copy link

Consider the following code sample.

from typing import LiteralString

def func1(a: list[LiteralString]):
    v1: list[str] = a   # Should generate a type error but does not currently

I just fixed a related bug in pyright.

Mypy version 1.5.1

@erictraut erictraut added the bug mypy got something wrong label Sep 24, 2023
@JelleZijlstra
Copy link
Member

This is because internally mypy currently treats LiteralString as an alias of str as a stopgap until we get full support (#12554). Closing as a duplicate of that issue.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2023
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