mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +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
|
||||
/// ```python
|
||||
/// with open("file", "rwx") as f:
|
||||
/// return f.read()
|
||||
/// content = f.read()
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
///
|
||||
/// ```python
|
||||
/// with open("file", "r") as f:
|
||||
/// return f.read()
|
||||
/// content = f.read()
|
||||
/// ```
|
||||
///
|
||||
/// ## References
|
||||
|
|
|
@ -15,21 +15,23 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
|||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// for x in foo:
|
||||
/// yield x
|
||||
/// def bar():
|
||||
/// for x in foo:
|
||||
/// yield x
|
||||
///
|
||||
/// global y
|
||||
/// for y in foo:
|
||||
/// yield y
|
||||
/// global y
|
||||
/// for y in foo:
|
||||
/// yield y
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// yield from foo
|
||||
/// def bar():
|
||||
/// yield from foo
|
||||
///
|
||||
/// for _element in foo:
|
||||
/// y = _element
|
||||
/// yield y
|
||||
/// for _element in foo:
|
||||
/// y = _element
|
||||
/// yield y
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix safety
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue