Add "Notebook behavior" section for F704, PLE1142 (#14266)

## Summary

Move the relevant contents into "Notebook behavior" section similar to
other rules.
This commit is contained in:
Dhruv Manilawala 2024-11-11 16:24:28 +05:30 committed by GitHub
parent 84d4f114ef
commit 13883414af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -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)
///

View file

@ -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)