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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
  --> import_as.py:24:1
   |
22 | foo.readlink(p)
23 | foo.stat(p)
24 | foo_p.isabs(p)
   | ^^^^^^^^^^^
25 | foo_p.join(p, q)
26 | foo.sep.join([p, q])
   |
help: Replace with `Path(...).is_absolute()`

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

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

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

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

PTH120 `os.path.dirname()` should be replaced by `Path.parent`
  --> import_as.py:29:1
   |
27 | foo.sep.join((p, q))
28 | foo_p.basename(p)
29 | foo_p.dirname(p)
   | ^^^^^^^^^^^^^
30 | foo_p.samefile(p)
31 | foo_p.splitext(p)
   |
help: Replace with `Path(...).parent`

PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
  --> import_as.py:30:1
   |
28 | foo_p.basename(p)
29 | foo_p.dirname(p)
30 | foo_p.samefile(p)
   | ^^^^^^^^^^^^^^
31 | foo_p.splitext(p)
   |
help: Replace with `Path(...).samefile()`

PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent`
  --> import_as.py:31:1
   |
29 | foo_p.dirname(p)
30 | foo_p.samefile(p)
31 | foo_p.splitext(p)
   | ^^^^^^^^^^^^^^
   |
