---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
---
B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:9:9
   |
 7 | def broken():
 8 |     if True:
 9 |         return [1, 2, 3]
   |         ^^^^^^^^^^^^^^^^
10 |
11 |     yield 3
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:36:5
   |
35 | def broken2():
36 |     return [3, 2, 1]
   |     ^^^^^^^^^^^^^^^^
37 |
38 |     yield from not_broken()
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:56:5
   |
55 | def broken3():
56 |     return (yield from [])
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:61:5
   |
59 | def broken4():
60 |     x = yield from []
61 |     return x
   |     ^^^^^^^^
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:72:5
   |
71 |     inner((yield from []))
72 |     return x
   |     ^^^^^^^^
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:83:5
   |
81 | async def broken6():
82 |     yield 1
83 |     return foo()
   |     ^^^^^^^^^^^^
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
  --> B901.py:88:5
   |
86 | async def broken7():
87 |     yield 1
88 |     return [1, 2, 3]
   |     ^^^^^^^^^^^^^^^^
   |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
   --> B901.py:116:5
    |
114 | def pytest_configure():
115 |     yield
116 |     return "should error"
    |     ^^^^^^^^^^^^^^^^^^^^^
    |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
   --> B901.py:122:5
    |
120 | def pytest_unconfigure():
121 |     yield
122 |     return "should error"
    |     ^^^^^^^^^^^^^^^^^^^^^
    |

B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior
   --> B901.py:128:5
    |
126 | def my_fixture():
127 |     yield
128 |     return "should error"
    |     ^^^^^^^^^^^^^^^^^^^^^
    |
