mirror of https://github.com/astral-sh/ruff
Fix false-positive for TRY302 if exception cause is given (#4559)
This commit is contained in:
parent
6db05d8cc6
commit
8ca3977602
|
|
@ -68,6 +68,18 @@ def bad():
|
|||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def fine():
|
||||
try:
|
||||
process()
|
||||
except Exception as e:
|
||||
raise e from None
|
||||
|
||||
def fine():
|
||||
try:
|
||||
process()
|
||||
except Exception as e:
|
||||
raise e from Exception
|
||||
|
||||
def fine():
|
||||
try:
|
||||
process()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ pub(crate) fn useless_try_except(checker: &mut Checker, handlers: &[Excepthandle
|
|||
.iter()
|
||||
.map(|handler| {
|
||||
let ExceptHandler(ExcepthandlerExceptHandler { name, body, .. }) = handler;
|
||||
let Some(Stmt::Raise(ast::StmtRaise { exc, .. })) = &body.first() else {
|
||||
let Some(Stmt::Raise(ast::StmtRaise { exc, cause: None, .. })) = &body.first() else {
|
||||
return None;
|
||||
};
|
||||
if let Some(expr) = exc {
|
||||
|
|
|
|||
Loading…
Reference in New Issue