read-whole-file (FURB101)
Preview (since v0.1.2) · Related issues · View source
Derived from the refurb linter.
Fix is sometimes available.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for uses of open and read that can be replaced by pathlib
methods, like Path.read_text and Path.read_bytes.
Why is this bad?
When reading the entire contents of a file into a variable, it's simpler
and more concise to use pathlib methods like Path.read_text and
Path.read_bytes instead of open and read calls via with statements.
Example
Use instead:
Fix Safety
This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression.