---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP020 [*] Use builtin `open`
 --> UP020.py:3:6
  |
1 | import io
2 |
3 | with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f:
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |     print(f.read())
  |
help: Replace with builtin `open`
  |
2 |
  - with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f:
3 + with open("f.txt", mode="r", buffering=-1, **kwargs) as f:
4 |     print(f.read())
  |

UP020 [*] Use builtin `open`
 --> UP020.py:8:6
  |
6 | from io import open
7 |
8 | with open("f.txt") as f:
  |      ^^^^^^^^^^^^^
9 |     print(f.read())
  |
help: Replace with builtin `open`
   |
6  | from io import open
7  + import builtins
8  |
   - with open("f.txt") as f:
9  + with builtins.open("f.txt") as f:
10 |     print(f.read())
   |

UP020 [*] Use builtin `open`
  --> UP020.py:13:5
   |
12 |   with (
13 | /     io  # text
14 | |     # text
15 | |     .open("file.txt") as f
   | |_____________________^
16 |   ):
17 |       ...
   |
help: Replace with builtin `open`
   |
6  | from io import open
7  + import builtins
8  |
--------------------------------------------------------------------------------
13 | with (
   -     io  # text
   -     # text
   -     .open("file.txt") as f
14 +     builtins.open("file.txt") as f
15 | ):
   |
note: This is an unsafe fix and may change runtime behavior
