Skip to content

Wrong overload for str.join / assignability to Iterable[_] #306

@sharkdp

Description

@sharkdp

The return type of str.join should be str here, not LiteralString:

from typing import reveal_type

def _(pair: tuple[str, str]):
    reveal_type(", ".join(pair))  # ty: LiteralString

Seems related to the fact that we seem to think that tuple[str, str] or Iterable[str] is assignable to Iterable[LiteralString]:

from typing import LiteralString, Iterable

def _(iterable: Iterable[str]):
    x: Iterable[LiteralString] = iterable  # this should be an error

https://play.ty.dev/b1a1e84a-6cb9-4b46-89aa-3567a830bad0

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProtocolsbugSomething isn't workinggenericsBugs or features relating to ty's generics implementationtype propertiessubtyping, assignability, equivalence, and more

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions