---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()`
 --> full_name.py:7:5
  |
5 | q = "bar"
6 |
7 | a = os.path.abspath(p)
  |     ^^^^^^^^^^^^^^^
8 | aa = os.chmod(p)
9 | aaa = os.mkdir(p)
  |
help: Replace with `Path(...).resolve()`
  |
2 | import os.path
3 + import pathlib
4 |
5 | p = "/foo"
6 | q = "bar"
7 |
  - a = os.path.abspath(p)
8 + a = pathlib.Path(p).resolve()
9 | aa = os.chmod(p)
  |
note: This is an unsafe fix and may change runtime behavior

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

PTH102 [*] `os.mkdir()` should be replaced by `Path.mkdir()`
  --> full_name.py:9:7
   |
 7 | a = os.path.abspath(p)
 8 | aa = os.chmod(p)
 9 | aaa = os.mkdir(p)
   |       ^^^^^^^^
10 | os.makedirs(p)
11 | os.rename(p)
   |
help: Replace with `Path(...).mkdir()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
9  | aa = os.chmod(p)
   - aaa = os.mkdir(p)
10 + aaa = pathlib.Path(p).mkdir()
11 | os.makedirs(p)
   |

PTH103 [*] `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
  --> full_name.py:10:1
   |
 8 | aa = os.chmod(p)
 9 | aaa = os.mkdir(p)
10 | os.makedirs(p)
   | ^^^^^^^^^^^
11 | os.rename(p)
12 | os.replace(p)
   |
help: Replace with `Path(...).mkdir(parents=True)`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
10 | aaa = os.mkdir(p)
   - os.makedirs(p)
11 + pathlib.Path(p).mkdir(parents=True)
12 | os.rename(p)
   |

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

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

PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()`
  --> full_name.py:13:1
   |
11 | os.rename(p)
12 | os.replace(p)
13 | os.rmdir(p)
   | ^^^^^^^^
14 | os.remove(p)
15 | os.unlink(p)
   |
help: Replace with `Path(...).rmdir()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
13 | os.replace(p)
   - os.rmdir(p)
14 + pathlib.Path(p).rmdir()
15 | os.remove(p)
   |

PTH107 [*] `os.remove()` should be replaced by `Path.unlink()`
  --> full_name.py:14:1
   |
12 | os.replace(p)
13 | os.rmdir(p)
14 | os.remove(p)
   | ^^^^^^^^^
15 | os.unlink(p)
16 | os.getcwd(p)
   |
help: Replace with `Path(...).unlink()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
14 | os.rmdir(p)
   - os.remove(p)
15 + pathlib.Path(p).unlink()
16 | os.unlink(p)
   |

PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()`
  --> full_name.py:15:1
   |
13 | os.rmdir(p)
14 | os.remove(p)
15 | os.unlink(p)
   | ^^^^^^^^^
16 | os.getcwd(p)
17 | b = os.path.exists(p)
   |
help: Replace with `Path(...).unlink()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
15 | os.remove(p)
   - os.unlink(p)
16 + pathlib.Path(p).unlink()
17 | os.getcwd(p)
   |

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

PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()`
  --> full_name.py:17:5
   |
15 | os.unlink(p)
16 | os.getcwd(p)
17 | b = os.path.exists(p)
   |     ^^^^^^^^^^^^^^
18 | bb = os.path.expanduser(p)
19 | bbb = os.path.isdir(p)
   |
help: Replace with `Path(...).exists()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
17 | os.getcwd(p)
   - b = os.path.exists(p)
18 + b = pathlib.Path(p).exists()
19 | bb = os.path.expanduser(p)
   |

PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
  --> full_name.py:18:6
   |
16 | os.getcwd(p)
17 | b = os.path.exists(p)
18 | bb = os.path.expanduser(p)
   |      ^^^^^^^^^^^^^^^^^^
19 | bbb = os.path.isdir(p)
20 | bbbb = os.path.isfile(p)
   |
help: Replace with `Path(...).expanduser()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
18 | b = os.path.exists(p)
   - bb = os.path.expanduser(p)
19 + bb = pathlib.Path(p).expanduser()
20 | bbb = os.path.isdir(p)
   |
note: This is an unsafe fix and may change runtime behavior

PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()`
  --> full_name.py:19:7
   |
17 | b = os.path.exists(p)
18 | bb = os.path.expanduser(p)
19 | bbb = os.path.isdir(p)
   |       ^^^^^^^^^^^^^
20 | bbbb = os.path.isfile(p)
21 | bbbbb = os.path.islink(p)
   |
help: Replace with `Path(...).is_dir()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
19 | bb = os.path.expanduser(p)
   - bbb = os.path.isdir(p)
20 + bbb = pathlib.Path(p).is_dir()
21 | bbbb = os.path.isfile(p)
   |

PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()`
  --> full_name.py:20:8
   |
18 | bb = os.path.expanduser(p)
19 | bbb = os.path.isdir(p)
20 | bbbb = os.path.isfile(p)
   |        ^^^^^^^^^^^^^^
21 | bbbbb = os.path.islink(p)
22 | os.readlink(p)
   |
help: Replace with `Path(...).is_file()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
20 | bbb = os.path.isdir(p)
   - bbbb = os.path.isfile(p)
21 + bbbb = pathlib.Path(p).is_file()
22 | bbbbb = os.path.islink(p)
   |

PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()`
  --> full_name.py:21:9
   |
19 | bbb = os.path.isdir(p)
20 | bbbb = os.path.isfile(p)
21 | bbbbb = os.path.islink(p)
   |         ^^^^^^^^^^^^^^
22 | os.readlink(p)
23 | os.stat(p)
   |
help: Replace with `Path(...).is_symlink()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
21 | bbbb = os.path.isfile(p)
   - bbbbb = os.path.islink(p)
22 + bbbbb = pathlib.Path(p).is_symlink()
23 | os.readlink(p)
   |

PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()`
  --> full_name.py:22:1
   |
20 | bbbb = os.path.isfile(p)
21 | bbbbb = os.path.islink(p)
22 | os.readlink(p)
   | ^^^^^^^^^^^
23 | os.stat(p)
24 | os.path.isabs(p)
   |
help: Replace with `Path(...).readlink()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
22 | bbbbb = os.path.islink(p)
   - os.readlink(p)
23 + pathlib.Path(p).readlink()
24 | os.stat(p)
   |

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

PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()`
  --> full_name.py:24:1
   |
22 | os.readlink(p)
23 | os.stat(p)
24 | os.path.isabs(p)
   | ^^^^^^^^^^^^^
25 | os.path.join(p, q)
26 | os.sep.join([p, q])
   |
help: Replace with `Path(...).is_absolute()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
24 | os.stat(p)
   - os.path.isabs(p)
25 + pathlib.Path(p).is_absolute()
26 | os.path.join(p, q)
   |

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

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

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

PTH119 [*] `os.path.basename()` should be replaced by `Path.name`
  --> full_name.py:28:1
   |
26 | os.sep.join([p, q])
27 | os.sep.join((p, q))
28 | os.path.basename(p)
   | ^^^^^^^^^^^^^^^^
29 | os.path.dirname(p)
30 | os.path.samefile(p)
   |
help: Replace with `Path(...).name`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
28 | os.sep.join((p, q))
   - os.path.basename(p)
29 + pathlib.Path(p).name
30 | os.path.dirname(p)
   |
note: This is an unsafe fix and may change runtime behavior

PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent`
  --> full_name.py:29:1
   |
27 | os.sep.join((p, q))
28 | os.path.basename(p)
29 | os.path.dirname(p)
   | ^^^^^^^^^^^^^^^
30 | os.path.samefile(p)
31 | os.path.splitext(p)
   |
help: Replace with `Path(...).parent`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
29 | os.path.basename(p)
   - os.path.dirname(p)
30 + pathlib.Path(p).parent
31 | os.path.samefile(p)
   |
note: This is an unsafe fix and may change runtime behavior

PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
  --> full_name.py:30:1
   |
28 | os.path.basename(p)
29 | os.path.dirname(p)
30 | os.path.samefile(p)
   | ^^^^^^^^^^^^^^^^
31 | os.path.splitext(p)
32 | 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`
  --> full_name.py:31:1
   |
29 | os.path.dirname(p)
30 | os.path.samefile(p)
31 | os.path.splitext(p)
   | ^^^^^^^^^^^^^^^^
32 | with open(p) as fp:
33 |     fp.read()
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:32:6
   |
30 | os.path.samefile(p)
31 | os.path.splitext(p)
32 | with open(p) as fp:
   |      ^^^^
33 |     fp.read()
34 | open(p).close()
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
32 | os.path.splitext(p)
   - with open(p) as fp:
33 + with pathlib.Path(p).open() as fp:
34 |     fp.read()
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:34:1
   |
32 | with open(p) as fp:
33 |     fp.read()
34 | open(p).close()
   | ^^^^
35 | os.getcwdb(p)
36 | os.path.join(p, *q)
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
34 |     fp.read()
   - open(p).close()
35 + pathlib.Path(p).open().close()
36 | os.getcwdb(p)
   |

PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
  --> full_name.py:35:1
   |
33 |     fp.read()
34 | open(p).close()
35 | os.getcwdb(p)
   | ^^^^^^^^^^
36 | os.path.join(p, *q)
37 | os.sep.join(p, *q)
   |
help: Replace with `Path.cwd()`

PTH118 `os.path.join()` should be replaced by `Path.joinpath()`
  --> full_name.py:36:1
   |
34 | open(p).close()
35 | os.getcwdb(p)
36 | os.path.join(p, *q)
   | ^^^^^^^^^^^^
37 | os.sep.join(p, *q)
   |

PTH118 `os.sep.join()` should be replaced by `Path.joinpath()`
  --> full_name.py:37:1
   |
35 | os.getcwdb(p)
36 | os.path.join(p, *q)
37 | os.sep.join(p, *q)
   | ^^^^^^^^^^^
38 |
39 | # https://github.com/astral-sh/ruff/issues/7620
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:46:1
   |
44 | open(p, closefd=False)
45 | open(p, opener=opener)
46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
   | ^^^^
47 | open(p, 'r', - 1, None, None, None, True, None)
48 | open(p, 'r', - 1, None, None, None, False, opener)
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
46 | open(p, opener=opener)
   - open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
47 + pathlib.Path(p).open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)
48 | open(p, 'r', - 1, None, None, None, True, None)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:47:1
   |
45 | open(p, opener=opener)
46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
47 | open(p, 'r', - 1, None, None, None, True, None)
   | ^^^^
48 | open(p, 'r', - 1, None, None, None, False, opener)
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
47 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
   - open(p, 'r', - 1, None, None, None, True, None)
48 + pathlib.Path(p).open('r', - 1, None, None, None)
49 | open(p, 'r', - 1, None, None, None, False, opener)
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:65:1
   |
63 | open(f())
64 |
65 | open(b"foo")
   | ^^^^
66 | byte_str = b"bar"
67 | open(byte_str)
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
65 |
   - open(b"foo")
66 + pathlib.Path(b"foo").open()
67 | byte_str = b"bar"
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:67:1
   |
65 | open(b"foo")
66 | byte_str = b"bar"
67 | open(byte_str)
   | ^^^^
68 |
69 | def bytes_str_func() -> bytes:
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
67 | byte_str = b"bar"
   - open(byte_str)
68 + pathlib.Path(byte_str).open()
69 |
   |

PTH123 [*] `open()` should be replaced by `Path.open()`
  --> full_name.py:71:1
   |
69 | def bytes_str_func() -> bytes:
70 |     return b"foo"
71 | open(bytes_str_func())
   | ^^^^
72 |
73 | # https://github.com/astral-sh/ruff/issues/17693
   |
help: Replace with `Path.open()`
   |
2  | import os.path
3  + import pathlib
4  |
--------------------------------------------------------------------------------
71 |     return b"foo"
   - open(bytes_str_func())
72 + pathlib.Path(bytes_str_func()).open()
73 |
   |

PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
   --> full_name.py:108:1
    |
106 | os.replace("src", "dst", dst_dir_fd=2)
107 |
108 | os.getcwd()
    | ^^^^^^^^^
109 | os.getcwdb()
    |
help: Replace with `Path.cwd()`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
108 |
    - os.getcwd()
109 + pathlib.Path.cwd()
110 | os.getcwdb()
    |

PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
   --> full_name.py:109:1
    |
108 | os.getcwd()
109 | os.getcwdb()
    | ^^^^^^^^^^
110 |
111 | os.mkdir(path="directory")
    |
help: Replace with `Path.cwd()`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
109 | os.getcwd()
    - os.getcwdb()
110 + pathlib.Path.cwd()
111 |
    |

PTH102 [*] `os.mkdir()` should be replaced by `Path.mkdir()`
   --> full_name.py:111:1
    |
109 | os.getcwdb()
110 |
111 | os.mkdir(path="directory")
    | ^^^^^^^^
112 |
113 | os.mkdir(
    |
help: Replace with `Path(...).mkdir()`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
111 |
    - os.mkdir(path="directory")
112 + pathlib.Path("directory").mkdir()
113 |
    |

PTH102 [*] `os.mkdir()` should be replaced by `Path.mkdir()`
   --> full_name.py:113:1
    |
111 | os.mkdir(path="directory")
112 |
113 | os.mkdir(
    | ^^^^^^^^
114 |     # comment 1
115 |     "directory",
    |
help: Replace with `Path(...).mkdir()`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
113 |
    - os.mkdir(
    -     # comment 1
    -     "directory",
    -     mode=0o777
    - )
114 + pathlib.Path("directory").mkdir(mode=0o777)
115 |
    |
note: This is an unsafe fix and may change runtime behavior

PTH103 [*] `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
   --> full_name.py:121:1
    |
119 | os.mkdir("directory", mode=0o777, dir_fd=1)
120 |
121 | os.makedirs("name", 0o777, exist_ok=False)
    | ^^^^^^^^^^^
122 |
123 | os.makedirs("name", 0o777, False)
    |
help: Replace with `Path(...).mkdir(parents=True)`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
121 |
    - os.makedirs("name", 0o777, exist_ok=False)
122 + pathlib.Path("name").mkdir(0o777, exist_ok=False, parents=True)
123 |
    |

PTH103 [*] `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
   --> full_name.py:123:1
    |
121 | os.makedirs("name", 0o777, exist_ok=False)
122 |
123 | os.makedirs("name", 0o777, False)
    | ^^^^^^^^^^^
124 |
125 | os.makedirs(name="name", mode=0o777, exist_ok=False)
    |
help: Replace with `Path(...).mkdir(parents=True)`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
123 |
    - os.makedirs("name", 0o777, False)
124 + pathlib.Path("name").mkdir(0o777, True, False)
125 |
    |

PTH103 [*] `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
   --> full_name.py:125:1
    |
123 | os.makedirs("name", 0o777, False)
124 |
125 | os.makedirs(name="name", mode=0o777, exist_ok=False)
    | ^^^^^^^^^^^
126 |
127 | os.makedirs("name", unknown_kwarg=True)
    |
help: Replace with `Path(...).mkdir(parents=True)`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
125 |
    - os.makedirs(name="name", mode=0o777, exist_ok=False)
126 + pathlib.Path("name").mkdir(mode=0o777, exist_ok=False, parents=True)
127 |
    |

PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
   --> full_name.py:127:1
    |
125 | os.makedirs(name="name", mode=0o777, exist_ok=False)
126 |
127 | os.makedirs("name", unknown_kwarg=True)
    | ^^^^^^^^^^^
128 |
129 | # https://github.com/astral-sh/ruff/issues/20134
    |
help: Replace with `Path(...).mkdir(parents=True)`

PTH101 [*] `os.chmod()` should be replaced by `Path.chmod()`
   --> full_name.py:130:1
    |
129 | # https://github.com/astral-sh/ruff/issues/20134
130 | os.chmod("pth1_link", mode=0o600, follow_symlinks=      False    )
    | ^^^^^^^^
131 | os.chmod("pth1_link", mode=0o600, follow_symlinks=True)
    |
help: Replace with `Path(...).chmod(...)`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
130 | # https://github.com/astral-sh/ruff/issues/20134
    - os.chmod("pth1_link", mode=0o600, follow_symlinks=      False    )
131 + pathlib.Path("pth1_link").chmod(mode=0o600, follow_symlinks=      False)
132 | os.chmod("pth1_link", mode=0o600, follow_symlinks=True)
    |

PTH101 [*] `os.chmod()` should be replaced by `Path.chmod()`
   --> full_name.py:131:1
    |
129 | # https://github.com/astral-sh/ruff/issues/20134
130 | os.chmod("pth1_link", mode=0o600, follow_symlinks=      False    )
131 | os.chmod("pth1_link", mode=0o600, follow_symlinks=True)
    | ^^^^^^^^
132 |
133 | # Only diagnostic
    |
help: Replace with `Path(...).chmod(...)`
    |
2   | import os.path
3   + import pathlib
4   |
--------------------------------------------------------------------------------
131 | os.chmod("pth1_link", mode=0o600, follow_symlinks=      False    )
    - os.chmod("pth1_link", mode=0o600, follow_symlinks=True)
132 + pathlib.Path("pth1_link").chmod(mode=0o600, follow_symlinks=True)
133 |
    |

PTH101 `os.chmod()` should be replaced by `Path.chmod()`
   --> full_name.py:134:1
    |
133 | # Only diagnostic
134 | os.chmod("pth1_file", 0o700, None, True, 1, *[1], **{"x": 1}, foo=1)
    | ^^^^^^^^
135 |
136 | os.rename("pth1_file", "pth1_file1", None, None, 1, *[1], **{"x": 1}, foo=1)
    |
help: Replace with `Path(...).chmod(...)`

PTH104 `os.rename()` should be replaced by `Path.rename()`
   --> full_name.py:136:1
    |
134 | os.chmod("pth1_file", 0o700, None, True, 1, *[1], **{"x": 1}, foo=1)
135 |
136 | os.rename("pth1_file", "pth1_file1", None, None, 1, *[1], **{"x": 1}, foo=1)
    | ^^^^^^^^^
137 | os.replace("pth1_file1", "pth1_file", None, None, 1, *[1], **{"x": 1}, foo=1)
    |
help: Replace with `Path(...).rename(...)`

PTH105 `os.replace()` should be replaced by `Path.replace()`
   --> full_name.py:137:1
    |
136 | os.rename("pth1_file", "pth1_file1", None, None, 1, *[1], **{"x": 1}, foo=1)
137 | os.replace("pth1_file1", "pth1_file", None, None, 1, *[1], **{"x": 1}, foo=1)
    | ^^^^^^^^^^
138 |
139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1)
    |
help: Replace with `Path(...).replace(...)`

PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
   --> full_name.py:139:1
    |
137 | os.replace("pth1_file1", "pth1_file", None, None, 1, *[1], **{"x": 1}, foo=1)
138 |
139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1)
    | ^^^^^^^^^^^^^^^^
140 |
141 | # See: https://github.com/astral-sh/ruff/issues/21794
    |
help: Replace with `Path(...).samefile()`

PTH104 [*] `os.rename()` should be replaced by `Path.rename()`
   --> full_name.py:144:4
    |
142 | import sys
143 |
144 | if os.rename("pth1.py", "pth1.py.bak"):
    |    ^^^^^^^^^
145 |     print("rename: truthy")
146 | else:
    |
help: Replace with `Path(...).rename(...)`
    |
142 | import sys
143 + import pathlib
144 |
    - if os.rename("pth1.py", "pth1.py.bak"):
145 + if pathlib.Path("pth1.py").rename("pth1.py.bak"):
146 |     print("rename: truthy")
    |
note: This is an unsafe fix and may change runtime behavior

PTH105 [*] `os.replace()` should be replaced by `Path.replace()`
   --> full_name.py:149:4
    |
147 |     print("rename: falsey")
148 |
149 | if os.replace("pth1.py.bak", "pth1.py"):
    |    ^^^^^^^^^^
150 |     print("replace: truthy")
151 | else:
    |
help: Replace with `Path(...).replace(...)`
    |
142 | import sys
143 + import pathlib
144 |
--------------------------------------------------------------------------------
149 |
    - if os.replace("pth1.py.bak", "pth1.py"):
150 + if pathlib.Path("pth1.py.bak").replace("pth1.py"):
151 |     print("replace: truthy")
    |
note: This is an unsafe fix and may change runtime behavior

PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
   --> full_name.py:155:14
    |
154 | try:
155 |     for _ in os.getcwd():
    |              ^^^^^^^^^
156 |         print("getcwd: iterable")
157 |         break
    |
help: Replace with `Path.cwd()`
    |
142 | import sys
143 + import pathlib
144 |
--------------------------------------------------------------------------------
155 | try:
    -     for _ in os.getcwd():
156 +     for _ in pathlib.Path.cwd():
157 |         print("getcwd: iterable")
    |
note: This is an unsafe fix and may change runtime behavior

PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
   --> full_name.py:162:14
    |
161 | try:
162 |     for _ in os.getcwdb():
    |              ^^^^^^^^^^
163 |         print("getcwdb: iterable")
164 |         break
    |
help: Replace with `Path.cwd()`
    |
142 | import sys
143 + import pathlib
144 |
--------------------------------------------------------------------------------
162 | try:
    -     for _ in os.getcwdb():
163 +     for _ in pathlib.Path.cwd():
164 |         print("getcwdb: iterable")
    |
note: This is an unsafe fix and may change runtime behavior

PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()`
   --> full_name.py:169:14
    |
168 | try:
169 |     for _ in os.readlink(sys.executable):
    |              ^^^^^^^^^^^
170 |         print("readlink: iterable")
171 |         break
    |
help: Replace with `Path(...).readlink()`
    |
142 | import sys
143 + import pathlib
144 |
--------------------------------------------------------------------------------
169 | try:
    -     for _ in os.readlink(sys.executable):
170 +     for _ in pathlib.Path(sys.executable).readlink():
171 |         print("readlink: iterable")
    |
note: This is an unsafe fix and may change runtime behavior

PTH101 [*] `os.chmod()` should be replaced by `Path.chmod()`
   --> full_name.py:187:1
    |
186 | os.chmod(_AttrHolder.fd, 0o644)    # Suppressed: resolved as `int`
187 | os.chmod(_AttrHolder.name, 0o644)  # Diagnostic + fix: resolved as `str`
    | ^^^^^^^^
    |
help: Replace with `Path(...).chmod(...)`
    |
142 | import sys
143 + import pathlib
144 |
--------------------------------------------------------------------------------
187 | os.chmod(_AttrHolder.fd, 0o644)    # Suppressed: resolved as `int`
    - os.chmod(_AttrHolder.name, 0o644)  # Diagnostic + fix: resolved as `str`
188 + pathlib.Path(_AttrHolder.name).chmod(0o644)  # Diagnostic + fix: resolved as `str`
    |
