---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB101 [*] `open` and `read` should be replaced by `Path("file.txt").read_text(encoding="utf-8")`
 --> FURB101_2.py:2:6
  |
1 | # FURB101
2 | with open("file.txt", encoding="utf-8") as f:
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 |     _ = f.read()
4 | f = object()
  |
help: Replace with `Path("file.txt").read_text(encoding="utf-8")`
  |
1 | # FURB101
  - with open("file.txt", encoding="utf-8") as f:
  -     _ = f.read()
2 + import pathlib
3 + _ = pathlib.Path("file.txt").read_text(encoding="utf-8")
4 | f = object()
  |

FURB101 [*] `open` and `read` should be replaced by `Path("config.yaml").read_text(encoding="utf-8")`
  --> FURB101_2.py:13:6
   |
12 | # Rebinding in a later `with ... as config_file` should not suppress this one.
13 | with open("config.yaml", encoding="utf-8") as config_file:
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 |     config_raw = config_file.read()
   |
help: Replace with `Path("config.yaml").read_text(encoding="utf-8")`
   |
1  | # FURB101
2  + import pathlib
3  | with open("file.txt", encoding="utf-8") as f:
--------------------------------------------------------------------------------
13 | # Rebinding in a later `with ... as config_file` should not suppress this one.
   - with open("config.yaml", encoding="utf-8") as config_file:
   -     config_raw = config_file.read()
14 + config_raw = pathlib.Path("config.yaml").read_text(encoding="utf-8")
15 |
   |
