---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
  --> import_from.py:9:5
   |
 7 | q = "bar"
 8 |
 9 | a = abspath(p)
   |     ^^^^^^^
10 | aa = chmod(p)
11 | aaa = mkdir(p)
   |
help: Replace with `Path(...).resolve()`

PTH101 `os.chmod()` should be replaced by `Path.chmod()`
  --> import_from.py:10:6
   |
 9 | a = abspath(p)
10 | aa = chmod(p)
   |      ^^^^^
11 | aaa = mkdir(p)
12 | makedirs(p)
   |
help: Replace with `Path(...).chmod(...)`

PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
  --> import_from.py:11:7
   |
 9 | a = abspath(p)
10 | aa = chmod(p)
11 | aaa = mkdir(p)
   |       ^^^^^
12 | makedirs(p)
13 | rename(p)
   |
help: Replace with `Path(...).mkdir()`

PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
  --> import_from.py:12:1
   |
10 | aa = chmod(p)
11 | aaa = mkdir(p)
12 | makedirs(p)
   | ^^^^^^^^
13 | rename(p)
14 | replace(p)
   |
help: Replace with `Path(...).mkdir(parents=True)`

PTH104 `os.rename()` should be replaced by `Path.rename()`
  --> import_from.py:13:1
   |
11 | aaa = mkdir(p)
12 | makedirs(p)
13 | rename(p)
   | ^^^^^^
14 | replace(p)
15 | rmdir(p)
   |
help: Replace with `Path(...).rename(...)`

PTH105 `os.replace()` should be replaced by `Path.replace()`
  --> import_from.py:14:1
   |
12 | makedirs(p)
13 | rename(p)
14 | replace(p)
   | ^^^^^^^
15 | rmdir(p)
16 | remove(p)
   |
help: Replace with `Path(...).replace(...)`

PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
  --> import_from.py:15:1
   |
13 | rename(p)
14 | replace(p)
15 | rmdir(p)
   | ^^^^^
16 | remove(p)
17 | unlink(p)
   |
help: Replace with `Path(...).rmdir()`

PTH107 `os.remove()` should be replaced by `Path.unlink()`
  --> import_from.py:16:1
   |
14 | replace(p)
15 | rmdir(p)
16 | remove(p)
   | ^^^^^^
17 | unlink(p)
18 | getcwd(p)
   |
help: Replace with `Path(...).unlink()`

PTH108 `os.unlink()` should be replaced by `Path.unlink()`
  --> import_from.py:17:1
   |
15 | rmdir(p)
16 | remove(p)
17 | unlink(p)
   | ^^^^^^
18 | getcwd(p)
19 | b = exists(p)
   |
help: Replace with `Path(...).unlink()`

PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
  --> import_from.py:18:1
   |
16 | remove(p)
17 | unlink(p)
18 | getcwd(p)
   | ^^^^^^
19 | b = exists(p)
20 | bb = expanduser(p)
   |
help: Replace with `Path.cwd()`

PTH110 `os.path.exists()` should be replaced by `Path.exists()`
  --> import_from.py:19:5
   |
17 | unlink(p)
18 | getcwd(p)
19 | b = exists(p)
   |     ^^^^^^
20 | bb = expanduser(p)
21 | bbb = isdir(p)
   |
help: Replace with `Path(...).exists()`

PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
  --> import_from.py:20:6
   |
18 | getcwd(p)
19 | b = exists(p)
20 | bb = expanduser(p)
   |      ^^^^^^^^^^
21 | bbb = isdir(p)
22 | bbbb = isfile(p)
   |
help: Replace with `Path(...).expanduser()`

PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
  --> import_from.py:21:7
   |
19 | b = exists(p)
20 | bb = expanduser(p)
21 | bbb = isdir(p)
   |       ^^^^^
22 | bbbb = isfile(p)
23 | bbbbb = islink(p)
   |
help: Replace with `Path(...).is_dir()`

PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
  --> import_from.py:22:8
   |
20 | bb = expanduser(p)
21 | bbb = isdir(p)
22 | bbbb = isfile(p)
   |        ^^^^^^
23 | bbbbb = islink(p)
24 | readlink(p)
   |
help: Replace with `Path(...).is_file()`

PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
  --> import_from.py:23:9
   |
21 | bbb = isdir(p)
22 | bbbb = isfile(p)
23 | bbbbb = islink(p)
   |         ^^^^^^
24 | readlink(p)
25 | stat(p)
   |
help: Replace with `Path(...).is_symlink()`

PTH115 `os.readlink()` should be replaced by `Path.readlink()`
  --> import_from.py:24:1
   |
22 | bbbb = isfile(p)
23 | bbbbb = islink(p)
24 | readlink(p)
   | ^^^^^^^^
25 | stat(p)
26 | isabs(p)
   |
help: Replace with `Path(...).readlink()`

PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
  --> import_from.py:25:1
   |
23 | bbbbb = islink(p)
24 | readlink(p)
25 | stat(p)
   | ^^^^
26 | isabs(p)
27 | join(p, q)
   |

PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
  --> import_from.py:26:1
   |
24 | readlink(p)
25 | stat(p)
26 | isabs(p)
   | ^^^^^
27 | join(p, q)
28 | sep.join((p, q))
   |
help: Replace with `Path(...).is_absolute()`

PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
  --> import_from.py:27:1
   |
25 | stat(p)
26 | isabs(p)
27 | join(p, q)
   | ^^^^
28 | sep.join((p, q))
29 | sep.join([p, q])
   |

PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
  --> import_from.py:28:1
   |
26 | isabs(p)
27 | join(p, q)
28 | sep.join((p, q))
   | ^^^^^^^^
29 | sep.join([p, q])
30 | basename(p)
   |

PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
  --> import_from.py:29:1
   |
27 | join(p, q)
28 | sep.join((p, q))
29 | sep.join([p, q])
   | ^^^^^^^^
30 | basename(p)
31 | dirname(p)
   |

PTH119 `os.path.basename()` should be replaced by `Path.name`
  --> import_from.py:30:1
   |
28 | sep.join((p, q))
29 | sep.join([p, q])
30 | basename(p)
   | ^^^^^^^^
31 | dirname(p)
32 | samefile(p)
   |
help: Replace with `Path(...).name`

PTH120 `os.path.dirname()` should be replaced by `Path.parent`
  --> import_from.py:31:1
   |
29 | sep.join([p, q])
30 | basename(p)
31 | dirname(p)
   | ^^^^^^^
32 | samefile(p)
33 | splitext(p)
   |
help: Replace with `Path(...).parent`

PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
  --> import_from.py:32:1
   |
30 | basename(p)
31 | dirname(p)
32 | samefile(p)
   | ^^^^^^^^
33 | splitext(p)
34 | with open(p) as fp:
   |
help: Replace with `Path(...).samefile()`

PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent`
  --> import_from.py:33:1
   |
31 | dirname(p)
32 | samefile(p)
33 | splitext(p)
   | ^^^^^^^^
34 | with open(p) as fp:
35 |     fp.read()
   |

PTH123 `open()` should be replaced by `Path.open()`
  --> import_from.py:34:6
   |
32 | samefile(p)
33 | splitext(p)
34 | with open(p) as fp:
   |      ^^^^
35 |     fp.read()
36 | open(p).close()
   |
help: Replace with `Path.open()`

PTH123 `open()` should be replaced by `Path.open()`
  --> import_from.py:36:1
   |
34 | with open(p) as fp:
35 |     fp.read()
36 | open(p).close()
   | ^^^^
   |
help: Replace with `Path.open()`

PTH123 `open()` should be replaced by `Path.open()`
  --> import_from.py:43:10
   |
41 |     from builtins import open
42 |
43 |     with open(p) as _: ...  # Error
   |          ^^^^
   |
help: Replace with `Path.open()`

PTH104 `os.rename()` should be replaced by `Path.rename()`
  --> import_from.py:53:1
   |
51 | file = "file_1.py"
52 |
53 | rename(file, "file_2.py")
   | ^^^^^^
54 |
55 | rename(
   |
help: Replace with `Path(...).rename(...)`

PTH104 `os.rename()` should be replaced by `Path.rename()`
  --> import_from.py:55:1
   |
53 | rename(file, "file_2.py")
54 |
55 | rename(
   | ^^^^^^
56 |     # commment 1
57 |     file, # comment 2
   |
help: Replace with `Path(...).rename(...)`

PTH104 `os.rename()` should be replaced by `Path.rename()`
  --> import_from.py:63:1
   |
61 | )
62 |
63 | rename(file, "file_2.py", src_dir_fd=None, dst_dir_fd=None)
   | ^^^^^^
64 |
65 | rename(file, "file_2.py", src_dir_fd=1)
   |
help: Replace with `Path(...).rename(...)`
