mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-09 13:18:18 +00:00
[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:
parent
afdfa042f3
commit
2680f2ed81
3 changed files with 55 additions and 35 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue