Skip to content

Fine-grained: Test "yield from" #4968

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

Merged
merged 2 commits into from
Apr 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test-data/unit/fine-grained.test
Original file line number Diff line number Diff line change
Expand Up @@ -5806,6 +5806,34 @@ class M(type):
==
a.py:2: error: Argument 1 to "f" of "M" has incompatible type "int"; expected "str"

[case testYieldFrom]
from typing import Iterator
from a import f

def g() -> Iterator[int]:
a = "string"
a = yield from f()

[file a.py]
from typing import Generator

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

[file a.py.2]
from typing import Generator

class A: pass

def f() -> Generator[int, None, A]:
yield 5
return A()

[out]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a test where f is turned into a normal function (just in case).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that this works but left the test out since this seems unlikely to break (to conserve test running times).

==
main:6: error: Incompatible types in assignment (expression has type "A", variable has type "str")

[case testFString]
from a import g
f'{g(1)}'
Expand Down