Skip to content

Commit

Permalink
Fix ecosystem regression
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanPlasse committed Aug 13, 2024
1 parent 4a17dfa commit 651fdc2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,11 @@ def bar() -> NoReturn:
if baz() > 3:
return 1
bar()


def f():
if a:
return b
else:
with c:
d
3 changes: 0 additions & 3 deletions crates/ruff_linter/src/rules/flake8_return/rules/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,6 @@ fn has_implicit_return(checker: &mut Checker, stmt: &Stmt) -> bool {
Stmt::With(ast::StmtWith { body, .. }) => {
if let Some(last_stmt) = body.last() {
if has_implicit_return(checker, last_stmt) {
if checker.settings.preview.is_disabled() {
add_return_none(checker, stmt);
}
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,21 @@ RET503.py:370:5: RET503 [*] Missing explicit `return` at the end of function abl
369 369 | return 1
370 370 | bar()
371 |+ return None
371 372 |
372 373 |
373 374 | def f():

RET503.py:378:13: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value
|
376 | else:
377 | with c:
378 | d
| ^ RET503
|
= help: Add explicit `return` statement

ℹ Unsafe fix
376 376 | else:
377 377 | with c:
378 378 | d
379 |+ return None
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,25 @@ RET503.py:370:5: RET503 [*] Missing explicit `return` at the end of function abl
369 369 | return 1
370 370 | bar()
371 |+ return None
371 372 |
372 373 |
373 374 | def f():

RET503.py:374:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value
|
373 | def f():
374 | if a:
| _____^
375 | | return b
376 | | else:
377 | | with c:
378 | | d
| |_____________^ RET503
|
= help: Add explicit `return` statement

ℹ Unsafe fix
376 376 | else:
377 377 | with c:
378 378 | d
379 |+ return None

0 comments on commit 651fdc2

Please sign in to comment.