Commit 854a27c
fix(rlc): skip nested function definitions to eliminate yield false positives
AST default DFS recursed into nested ``def`` / ``async def`` bodies,
counting their yield/await as part of the outer function's flow.
Typical false positive:
async def outer(...):
async def _inner():
yield chunk
The outer function has no yield, but _inner's yield was being counted
as the outer's, triggering RLC013 ("yield expires tracked vars").
Fix: override visit_FunctionDef / visit_AsyncFunctionDef as no-op so
nested function bodies are skipped under the current scope's analysis.
Trade-off: nested closures are not analyzed independently. In practice
nested closures rarely access ORM directly; analyzing them properly
would require a second pass with closure capture handling.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e1815ee commit 854a27c
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3422 | 3422 | | |
3423 | 3423 | | |
3424 | 3424 | | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
3425 | 3452 | | |
3426 | 3453 | | |
3427 | 3454 | | |
| |||
0 commit comments