yield-outside-function
What it does
Section titled “What it does”Reports a yield, yield from or await outside a function.
Why it matters
Section titled “Why it matters”Python rejects the file with a SyntaxError ('yield' outside function, 'await' outside function), so no code in it runs.
To fix, put the code in a function (an async def for await).
Example
Section titled “Example”...
...yield 1await x
def f(): class A: yield 1
try: pass...Configuration
Section titled “Configuration”python: lint: rules: yield-outside-function: warn # off, warn (default), errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line yield-outside-function in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | F704 |
full |