mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 20:30:49 +00:00
<!-- Thank you for contributing to Ruff! 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? - Does this pull request include references to any relevant issues? --> ## Summary Hi! 👋 Thanks for sharing ruff as software libre — it helps me keep Python code quality up with pre-commit, both locally and CI 🙏 While studying the examples at https://docs.astral.sh/ruff/rules/function-uses-loop-variable/#example I noticed that the last of the examples had a bug: prior to this fix, `ì` was passed to the lambda for `x` rather than for `i` — the two are mixed-up. The reason it's easy to overlook is because addition is an commutative operation and so `x + i` and `i + x` give the same result (and least with integers), despite the mix-up. For proof, let me demo the relevant part with before and after: ```python In [1]: from functools import partial In [2]: [partial(lambda x, i: (x, i), i)(123) for i in range(3)] Out[2]: [(0, 123), (1, 123), (2, 123)] In [3]: [partial(lambda x, i: (x, i), i=i)(123) for i in range(3)] Out[3]: [(123, 0), (123, 1), (123, 2)] ``` Does that make sense? ## Test Plan <!-- How was it tested? --> Was manually tested using IPython. CC @r4f @grandchild |
||
|---|---|---|
| .. | ||
| ruff | ||
| ruff_benchmark | ||
| ruff_cache | ||
| ruff_dev | ||
| ruff_diagnostics | ||
| ruff_formatter | ||
| ruff_index | ||
| ruff_linter | ||
| ruff_macros | ||
| ruff_notebook | ||
| ruff_python_ast | ||
| ruff_python_codegen | ||
| ruff_python_formatter | ||
| ruff_python_index | ||
| ruff_python_literal | ||
| ruff_python_parser | ||
| ruff_python_resolver | ||
| ruff_python_semantic | ||
| ruff_python_stdlib | ||
| ruff_python_trivia | ||
| ruff_server | ||
| ruff_shrinking | ||
| ruff_source_file | ||
| ruff_text_size | ||
| ruff_wasm | ||
| ruff_workspace | ||