[ty] Minor: test isolation (#19597)

## Summary

Split the "Generator functions" tests into two parts. The first part
(synchronous) refers to a function called `i` from a function `i2`. But
`i` is later redeclared in the asynchronous part, which was probably not
intended.
This commit is contained in:
David Peter 2025-07-28 15:52:59 +02:00 committed by GitHub
parent afdfa042f3
commit 2680f2ed81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 35 deletions

View file

@ -433,6 +433,8 @@ def f(cond: bool) -> str:
<!-- snapshot-diagnostics -->
### Synchronous
A function with a `yield` or `yield from` expression anywhere in its body is a
[generator function](https://docs.python.org/3/glossary.html#term-generator). A generator function
implicitly returns an instance of `types.GeneratorType` even if it does not contain any `return`
@ -461,6 +463,8 @@ def j() -> str: # error: [invalid-return-type]
yield 42
```
### Asynchronous
If it is an `async` function with a `yield` statement in its body, it is an
[asynchronous generator function](https://docs.python.org/3/glossary.html#term-asynchronous-generator).
An asynchronous generator function implicitly returns an instance of `types.AsyncGeneratorType` even