Skip to content

Literal strings should be assignable to Sequence[Unknown] #531

@sharkdp

Description

@sharkdp

Found this while analyzing common ecosystem false positives. I think this should work?

from typing import Sequence, Any

seq: Sequence[Any] = "abc"  #  `Literal["abc"]` is not assignable to `Sequence[Any]`

https://play.ty.dev/1059069f-082c-4e2f-a643-92b3f0d8583c

Both of these cases work:

seq: Sequence[Any] = some_str
seq: Sequence[str] = "abc"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions