From 13883414afeb4c36397bbe4d10d486b95ece7590 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Mon, 11 Nov 2024 16:24:28 +0530 Subject: [PATCH] Add "Notebook behavior" section for `F704`, `PLE1142` (#14266) ## Summary Move the relevant contents into "Notebook behavior" section similar to other rules. --- .../src/rules/pyflakes/rules/yield_outside_function.rs | 7 ++++--- .../src/rules/pylint/rules/await_outside_async.rs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs b/crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs index 4fa5d3e8d0..2657882a69 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs @@ -31,15 +31,16 @@ impl fmt::Display for DeferralKeyword { /// The use of `yield`, `yield from`, or `await` outside of a function will /// raise a `SyntaxError`. /// -/// As an exception, `await` is allowed at the top level of a Jupyter notebook -/// (see: [autoawait]). -/// /// ## Example /// ```python /// class Foo: /// yield 1 /// ``` /// +/// ## Notebook behavior +/// As an exception, `await` is allowed at the top level of a Jupyter notebook +/// (see: [autoawait]). +/// /// ## References /// - [Python documentation: `yield`](https://docs.python.org/3/reference/simple_stmts.html#the-yield-statement) /// diff --git a/crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs b/crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs index ecf82e7fff..d7ed9c4554 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs @@ -11,9 +11,6 @@ use crate::checkers::ast::Checker; /// ## Why is this bad? /// Using `await` outside an `async` function is a syntax error. /// -/// As an exception, `await` is allowed at the top level of a Jupyter notebook -/// (see: [autoawait]). -/// /// ## Example /// ```python /// import asyncio @@ -32,6 +29,10 @@ use crate::checkers::ast::Checker; /// await asyncio.sleep(1) /// ``` /// +/// ## Notebook behavior +/// As an exception, `await` is allowed at the top level of a Jupyter notebook +/// (see: [autoawait]). +/// /// ## References /// - [Python documentation: Await expression](https://docs.python.org/3/reference/expressions.html#await) /// - [PEP 492: Await Expression](https://peps.python.org/pep-0492/#await-expression)