Skip to content

Allow dict to take a Generator #4450

Closed
Closed
@tekumara

Description

@tekumara
from typing import Dict

d: Dict[str,str] = dict(token.split('=', 1) for token in ['a=b'])

Fails in mypy 0.782 with:

test/test.py:3: error: Generator has incompatible item type "List[str]"; expected "Tuple[str, str]"

And in pyright 1.1.62 with:

3:20 - error: No overloads for "dict(token.split('=', 1) for token in ['a=b'])" match parameters
  Argument types: (Generator[List[str]]) (reportGeneralTypeIssues)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions