mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 09:31:09 +00:00
Include inline instantiations when detecting loggers (#11154)
## Summary Closes https://github.com/astral-sh/ruff/issues/11031.
This commit is contained in:
parent
22d4f11348
commit
b15e9e6e05
3 changed files with 34 additions and 11 deletions
|
@ -25,6 +25,18 @@ pub fn is_logger_candidate(
|
|||
return false;
|
||||
};
|
||||
|
||||
// If the attribute is an inline instantiation, match against known constructors.
|
||||
if let Expr::Call(ast::ExprCall { func, .. }) = &**value {
|
||||
return semantic
|
||||
.resolve_qualified_name(func)
|
||||
.is_some_and(|qualified_name| {
|
||||
matches!(
|
||||
qualified_name.segments(),
|
||||
["logging", "getLogger" | "Logger"]
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
// If the symbol was imported from another module, ensure that it's either a user-specified
|
||||
// logger object, the `logging` module itself, or `flask.current_app.logger`.
|
||||
if let Some(qualified_name) = semantic.resolve_qualified_name(value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue