mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
Implement B021 (#719)
This commit is contained in:
parent
439642addf
commit
e4d168bb4f
9 changed files with 216 additions and 10 deletions
19
src/flake8_bugbear/plugins/f_string_docstring.rs
Normal file
19
src/flake8_bugbear/plugins/f_string_docstring.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::check_ast::Checker;
|
||||
use crate::checks::{Check, CheckKind};
|
||||
|
||||
/// B021
|
||||
pub fn f_string_docstring(checker: &mut Checker, body: &[Stmt]) {
|
||||
if let Some(stmt) = body.first() {
|
||||
if let StmtKind::Expr { value } = &stmt.node {
|
||||
if let ExprKind::JoinedStr { .. } = value.node {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::FStringDocstring,
|
||||
Range::from_located(stmt),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue