mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
[pylint
, pyupgrade
] Fix syntax errors in examples (PLW1501
, UP028
) (#19127)
## Summary From me and @ntBre's discussion in #19111. This PR makes these two examples into valid code, since they previously had `F701`-`F707` syntax errors. `SIM110` was already fixed in a different PR, I just forgot to pull.
This commit is contained in:
parent
411cccb35e
commit
f48a34fbab
2 changed files with 14 additions and 11 deletions
|
@ -24,13 +24,14 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
/// with open("file", "rwx") as f:
|
/// with open("file", "rwx") as f:
|
||||||
/// return f.read()
|
/// content = f.read()
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
|
///
|
||||||
/// ```python
|
/// ```python
|
||||||
/// with open("file", "r") as f:
|
/// with open("file", "r") as f:
|
||||||
/// return f.read()
|
/// content = f.read()
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
|
|
|
@ -15,21 +15,23 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
/// for x in foo:
|
/// def bar():
|
||||||
/// yield x
|
/// for x in foo:
|
||||||
|
/// yield x
|
||||||
///
|
///
|
||||||
/// global y
|
/// global y
|
||||||
/// for y in foo:
|
/// for y in foo:
|
||||||
/// yield y
|
/// yield y
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```python
|
/// ```python
|
||||||
/// yield from foo
|
/// def bar():
|
||||||
|
/// yield from foo
|
||||||
///
|
///
|
||||||
/// for _element in foo:
|
/// for _element in foo:
|
||||||
/// y = _element
|
/// y = _element
|
||||||
/// yield y
|
/// yield y
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Fix safety
|
/// ## Fix safety
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue