---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:8:1
   |
 6 | r_plus = "r+"
 7 |
 8 | builtins.open(file=_file)
   | ^^^^^^^^^^^^^
 9 |
10 | open(_file, "r+ ", -  1)
   |
help: Replace with `Path.open()`
  |
7 |
  - builtins.open(file=_file)
8 + Path(_file).open()
9 |
  |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:10:1
   |
 8 | builtins.open(file=_file)
 9 |
10 | open(_file, "r+ ", -  1)
   | ^^^^
11 | open(mode="wb", file=_file)
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
   |
help: Replace with `Path.open()`
   |
9  |
   - open(_file, "r+ ", -  1)
10 + Path(_file).open("r+ ", -  1)
11 | open(mode="wb", file=_file)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:11:1
   |
10 | open(_file, "r+ ", -  1)
11 | open(mode="wb", file=_file)
   | ^^^^
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
13 | open(_file, "r+", - 1, None, None, None, True, None)
   |
help: Replace with `Path.open()`
   |
10 | open(_file, "r+ ", -  1)
   - open(mode="wb", file=_file)
11 + Path(_file).open(mode="wb")
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:12:1
   |
10 | open(_file, "r+ ", -  1)
11 | open(mode="wb", file=_file)
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
   | ^^^^
13 | open(_file, "r+", - 1, None, None, None, True, None)
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
   |
help: Replace with `Path.open()`
   |
11 | open(mode="wb", file=_file)
   - open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
12 + Path(_file).open(mode="r+", buffering=-1, encoding="utf-8")
13 | open(_file, "r+", - 1, None, None, None, True, None)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:13:1
   |
11 | open(mode="wb", file=_file)
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
13 | open(_file, "r+", - 1, None, None, None, True, None)
   | ^^^^
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
   |
help: Replace with `Path.open()`
   |
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
   - open(_file, "r+", - 1, None, None, None, True, None)
13 + Path(_file).open("r+", - 1, None, None, None)
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:14:1
   |
12 | open(mode="r+", buffering=-1, file=_file, encoding="utf-8")
13 | open(_file, "r+", - 1, None, None, None, True, None)
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
   | ^^^^
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
16 | open(_file, f"  {r_plus}      ", -  1)
   |
help: Replace with `Path.open()`
   |
13 | open(_file, "r+", - 1, None, None, None, True, None)
   - open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
14 + Path(_file).open("r+", -1, None, None, None)
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:15:1
   |
13 | open(_file, "r+", - 1, None, None, None, True, None)
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
   | ^^^^
16 | open(_file, f"  {r_plus}      ", -  1)
17 | open(buffering=-      1, file=_file, encoding=         "utf-8")
   |
help: Replace with `Path.open()`
   |
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
   - open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
15 + Path(_file).open(mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
16 | open(_file, f"  {r_plus}      ", -  1)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:16:1
   |
14 | open(_file, "r+", -1, None, None, None, closefd=True, opener=None)
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
16 | open(_file, f"  {r_plus}      ", -  1)
   | ^^^^
17 | open(buffering=-      1, file=_file, encoding=         "utf-8")
   |
help: Replace with `Path.open()`
   |
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
   - open(_file, f"  {r_plus}      ", -  1)
16 + Path(_file).open(f"  {r_plus}      ", -  1)
17 | open(buffering=-      1, file=_file, encoding=         "utf-8")
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> PTH123.py:17:1
   |
15 | open(_file, mode="r+", buffering=-1, encoding=None, errors=None, newline=None)
16 | open(_file, f"  {r_plus}      ", -  1)
17 | open(buffering=-      1, file=_file, encoding=         "utf-8")
   | ^^^^
18 |
19 | # Only diagnostic
   |
help: Replace with `Path.open()`
   |
16 | open(_file, f"  {r_plus}      ", -  1)
   - open(buffering=-      1, file=_file, encoding=         "utf-8")
17 + Path(_file).open(buffering=-      1, encoding=         "utf-8")
18 |
   |

PTH123 `open()` should be replaced by `Path.open()`
  --> PTH123.py:20:1
   |
19 | # Only diagnostic
20 | open()
   | ^^^^
21 | open(_file, *_x)
22 | open(_file, "r+", unknown=True)
   |
help: Replace with `Path.open()`

PTH123 `open()` should be replaced by `Path.open()`
  --> PTH123.py:21:1
   |
19 | # Only diagnostic
20 | open()
21 | open(_file, *_x)
   | ^^^^
22 | open(_file, "r+", unknown=True)
23 | open(_file, "r+", closefd=False)
   |
help: Replace with `Path.open()`

PTH123 `open()` should be replaced by `Path.open()`
  --> PTH123.py:22:1
   |
20 | open()
21 | open(_file, *_x)
22 | open(_file, "r+", unknown=True)
   | ^^^^
23 | open(_file, "r+", closefd=False)
24 | open(_file, "r+", None, None, None, None, None, None, None)
   |
help: Replace with `Path.open()`
