mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-29 06:44:16 +00:00
Disable top-level docstring formatting for notebooks (#9957)
This commit is contained in:
parent
ab2253db03
commit
edfe8421ec
5 changed files with 123 additions and 9 deletions
|
@ -214,9 +214,9 @@ impl<'ast> PreorderVisitor<'ast> for FindEnclosingNode<'_, 'ast> {
|
|||
// Don't pick potential docstrings as the closest enclosing node because `suite.rs` than fails to identify them as
|
||||
// docstrings and docstring formatting won't kick in.
|
||||
// Format the enclosing node instead and slice the formatted docstring from the result.
|
||||
let is_maybe_docstring = node
|
||||
.as_stmt_expr()
|
||||
.is_some_and(|stmt| DocstringStmt::is_docstring_statement(stmt));
|
||||
let is_maybe_docstring = node.as_stmt_expr().is_some_and(|stmt| {
|
||||
DocstringStmt::is_docstring_statement(stmt, self.context.options().source_type())
|
||||
});
|
||||
|
||||
if is_maybe_docstring {
|
||||
return TraversalSignal::Skip;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue