ruff/crates
Dylan 1e8881f9af
[refurb] Mark fix as safe for readlines-in-for (FURB129) (#17644)
This PR promotes the fix applicability of [readlines-in-for
(FURB129)](https://docs.astral.sh/ruff/rules/readlines-in-for/#readlines-in-for-furb129)
to always safe.

In the original PR (https://github.com/astral-sh/ruff/pull/9880), the
author marked the rule as unsafe because Ruff's type inference couldn't
quite guarantee that we had an `IOBase` object in hand. Some false
positives were recorded in the test fixture. However, before the PR was
merged, Charlie added the necessary type inference and the false
positives went away.

According to the [Python
documentation](https://docs.python.org/3/library/io.html#io.IOBase), I
believe this fix is safe for any proper implementation of `IOBase`:

>[IOBase](https://docs.python.org/3/library/io.html#io.IOBase) (and its
subclasses) supports the iterator protocol, meaning that an
[IOBase](https://docs.python.org/3/library/io.html#io.IOBase) object can
be iterated over yielding the lines in a stream. Lines are defined
slightly differently depending on whether the stream is a binary stream
(yielding bytes), or a text stream (yielding character strings). See
[readline()](https://docs.python.org/3/library/io.html#io.IOBase.readline)
below.

and then in the [documentation for
`readlines`](https://docs.python.org/3/library/io.html#io.IOBase.readlines):

>Read and return a list of lines from the stream. hint can be specified
to control the number of lines read: no more lines will be read if the
total size (in bytes/characters) of all lines so far exceeds hint. [...]
>Note that it’s already possible to iterate on file objects using for
line in file: ... without calling file.readlines().

I believe that a careful reading of our [versioning
policy](https://docs.astral.sh/ruff/versioning/#version-changes)
requires that this change be deferred to a minor release - but please
correct me if I'm wrong!
2025-04-28 09:39:55 -05:00
..
red_knot [red-knot] Use 101 exit code when there's at least one diagnostic with severity 'fatal' (#17640) 2025-04-28 10:03:14 +02:00
red_knot_ide [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
red_knot_project [red-knot] Don't ignore hidden files by default (#17655) 2025-04-28 08:21:11 +02:00
red_knot_python_semantic [red-knot] TypedDict: No errors for introspection dunder attributes (#17677) 2025-04-28 13:28:43 +02:00
red_knot_server Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
red_knot_test Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
red_knot_vendored Sync vendored typeshed stubs (#17402) 2025-04-15 09:16:42 +02:00
red_knot_wasm [red-knot] Fix offset handling in playground for 2-code-point UTF16 characters (#17520) 2025-04-27 11:44:55 +01:00
ruff [flake8-pyi] Ensure Literal[None,] | Literal[None,] is not autofixed to None | None (PYI061) (#17659) 2025-04-28 12:23:29 +01:00
ruff_annotate_snippets ruff_annotate_snippets: address unused code warnings 2025-04-07 08:24:08 -04:00
ruff_benchmark [red-knot] make large-union benchmark slow again (#17418) 2025-04-16 14:05:42 +00:00
ruff_cache Fix cache key collisions for paths with separators (#12159) 2024-07-03 07:36:46 -05:00
ruff_db Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_dev Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_diagnostics Show errors for attempted fixes only when passed --verbose (#15237) 2025-01-03 08:50:13 -06:00
ruff_formatter Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_graph [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
ruff_index [red-knot] Don't use separate ID types for each alist (#16415) 2025-02-28 14:55:55 -05:00
ruff_linter [refurb] Mark fix as safe for readlines-in-for (FURB129) (#17644) 2025-04-28 09:39:55 -05:00
ruff_macros Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_notebook Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_python_ast Remove redundant type_to_visitor_function entries (#17564) 2025-04-23 09:27:00 +02:00
ruff_python_ast_integration_tests Visit Identifier node as part of the SourceOrderVisitor (#17110) 2025-04-01 16:58:09 +02:00
ruff_python_codegen Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_formatter Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_python_index Extract LineIndex independent methods from Locator (#13938) 2024-10-28 07:53:41 +00:00
ruff_python_literal Preserve triple quotes and prefixes for strings (#15818) 2025-02-04 08:41:06 -05:00
ruff_python_parser [syntax-errors] nonlocal declaration at module level (#17559) 2025-04-24 16:11:46 -04:00
ruff_python_resolver Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_semantic [pylint] Detect global declarations in module scope (PLE0118) (#17411) 2025-04-25 08:37:16 -04:00
ruff_python_stdlib Revert "Add all PEP-585 names to UP006 rule" (#15250) 2025-01-04 12:23:53 +01:00
ruff_python_trivia [red-knot] Ignore surrounding whitespace when looking for <!-- snapshot-diagnostics --> directives in mdtests (#16380) 2025-02-27 13:25:31 +00:00
ruff_python_trivia_integration_tests Pass ParserOptions to the parser (#16220) 2025-02-19 10:50:50 -05:00
ruff_server Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_source_file [red-knot] Fix offset handling in playground for 2-code-point UTF16 characters (#17520) 2025-04-27 11:44:55 +01:00
ruff_text_size [ruff] itertools.starmap(..., zip(...)) (RUF058) (#15483) 2025-01-16 15:18:12 +01:00
ruff_wasm Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_workspace Use python.typing.org for typing documentation links (#17323) 2025-04-09 20:38:20 +02:00