Skip to content

yield from inside list comprehension gives wrong type #10188

@Akuli

Description

@Akuli

Bug Report

runtime and mypy types don't match, possibly related to #6457

To Reproduce

from typing import Generator

def f() -> Generator[int, None, str]:
    yield 1
    return "lol"

def g() -> Generator[int, None, None]:
    x = [(yield from f()) for lel in range(5)]
    print(x)        # <generator object g.<locals>.<listcomp> at 0x7fba92696a20>
    reveal_type(x)  # List[str]

g()

Expected Behavior

reveal_type outputting Generator[something] to match runtime

Actual Behavior

List[str]

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions