mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
[flake8-simplify
] Make example error out-of-the-box (SIM110
) (#19113)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Part of #18972 This PR makes [reimplemented-builtin (SIM110)](https://docs.astral.sh/ruff/rules/reimplemented-builtin/#reimplemented-builtin-sim110)'s example error out-of-the-box [Old example](https://play.ruff.rs/1c192e8b-13f8-4f07-8c35-9dcd516a4a02) ```py for item in iterable: if predicate(item): return True return False ``` [New example](https://play.ruff.rs/f77393ad-20b1-436f-a872-d3bccec7c829) ```py def foo(): for item in iterable: if predicate(item): return True return False ``` The "Use instead" section was also updated to reflect the change. ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
This commit is contained in:
parent
fc43d3c83e
commit
bf88fee428
1 changed files with 7 additions and 5 deletions
|
@ -23,15 +23,17 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
|||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// for item in iterable:
|
||||
/// if predicate(item):
|
||||
/// return True
|
||||
/// return False
|
||||
/// def foo():
|
||||
/// for item in iterable:
|
||||
/// if predicate(item):
|
||||
/// return True
|
||||
/// return False
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// return any(predicate(item) for item in iterable)
|
||||
/// def foo():
|
||||
/// return any(predicate(item) for item in iterable)
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix safety
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue