mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +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,6 +23,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
/// def foo():
|
||||||
/// for item in iterable:
|
/// for item in iterable:
|
||||||
/// if predicate(item):
|
/// if predicate(item):
|
||||||
/// return True
|
/// return True
|
||||||
|
@ -31,6 +32,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
||||||
///
|
///
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```python
|
/// ```python
|
||||||
|
/// def foo():
|
||||||
/// return any(predicate(item) for item in iterable)
|
/// return any(predicate(item) for item in iterable)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue