---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
 --> PTH203.py:5:1
  |
3 | from os.path import getatime
4 |
5 | os.path.getatime("filename")
  | ^^^^^^^^^^^^^^^^
6 | os.path.getatime(b"filename")
7 | os.path.getatime(Path("filename"))
  |
help: Replace with `Path.stat(...).st_atime`
  |
4 |
  - os.path.getatime("filename")
5 + Path("filename").stat().st_atime
6 | os.path.getatime(b"filename")
  |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
 --> PTH203.py:6:1
  |
5 | os.path.getatime("filename")
6 | os.path.getatime(b"filename")
  | ^^^^^^^^^^^^^^^^
7 | os.path.getatime(Path("filename"))
  |
help: Replace with `Path.stat(...).st_atime`
  |
5 | os.path.getatime("filename")
  - os.path.getatime(b"filename")
6 + Path(b"filename").stat().st_atime
7 | os.path.getatime(Path("filename"))
  |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
 --> PTH203.py:7:1
  |
5 | os.path.getatime("filename")
6 | os.path.getatime(b"filename")
7 | os.path.getatime(Path("filename"))
  | ^^^^^^^^^^^^^^^^
  |
help: Replace with `Path.stat(...).st_atime`
  |
6 | os.path.getatime(b"filename")
  - os.path.getatime(Path("filename"))
7 + Path("filename").stat().st_atime
8 |
  |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:10:1
   |
10 | getatime("filename")
   | ^^^^^^^^
11 | getatime(b"filename")
12 | getatime(Path("filename"))
   |
help: Replace with `Path.stat(...).st_atime`
   |
9  |
   - getatime("filename")
10 + Path("filename").stat().st_atime
11 | getatime(b"filename")
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:11:1
   |
10 | getatime("filename")
11 | getatime(b"filename")
   | ^^^^^^^^
12 | getatime(Path("filename"))
   |
help: Replace with `Path.stat(...).st_atime`
   |
10 | getatime("filename")
   - getatime(b"filename")
11 + Path(b"filename").stat().st_atime
12 | getatime(Path("filename"))
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:12:1
   |
10 | getatime("filename")
11 | getatime(b"filename")
12 | getatime(Path("filename"))
   | ^^^^^^^^
   |
help: Replace with `Path.stat(...).st_atime`
   |
11 | getatime(b"filename")
   - getatime(Path("filename"))
12 + Path("filename").stat().st_atime
13 |
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:17:1
   |
15 | file = __file__
16 |
17 | os.path.getatime(file)
   | ^^^^^^^^^^^^^^^^
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
   |
help: Replace with `Path.stat(...).st_atime`
   |
16 |
   - os.path.getatime(file)
17 + Path(file).stat().st_atime
18 | os.path.getatime(filename="filename")
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:18:1
   |
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
   | ^^^^^^^^^^^^^^^^
19 | os.path.getatime(filename=Path("filename"))
   |
help: Replace with `Path.stat(...).st_atime`
   |
17 | os.path.getatime(file)
   - os.path.getatime(filename="filename")
18 + Path("filename").stat().st_atime
19 | os.path.getatime(filename=Path("filename"))
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:19:1
   |
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
   | ^^^^^^^^^^^^^^^^
20 |
21 | os.path.getatime(  # comment 1
   |
help: Replace with `Path.stat(...).st_atime`
   |
18 | os.path.getatime(filename="filename")
   - os.path.getatime(filename=Path("filename"))
19 + Path("filename").stat().st_atime
20 |
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:21:1
   |
19 | os.path.getatime(filename=Path("filename"))
20 |
21 | os.path.getatime(  # comment 1
   | ^^^^^^^^^^^^^^^^
22 |     # comment 2
23 |     "filename"  # comment 3
   |
help: Replace with `Path.stat(...).st_atime`
   |
20 |
   - os.path.getatime(  # comment 1
   -     # comment 2
   -     "filename"  # comment 3
   -     # comment 4
   -     ,  # comment 5
   -     # comment 6
   - )  # comment 7
21 + Path("filename").stat().st_atime  # comment 7
22 |
   |
note: This is an unsafe fix and may change runtime behavior

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:29:1
   |
27 | )  # comment 7
28 |
29 | os.path.getatime("file" + "name")
   | ^^^^^^^^^^^^^^^^
30 |
31 | getatime(Path("filename").resolve())
   |
help: Replace with `Path.stat(...).st_atime`
   |
28 |
   - os.path.getatime("file" + "name")
29 + Path("file" + "name").stat().st_atime
30 |
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:31:1
   |
29 | os.path.getatime("file" + "name")
30 |
31 | getatime(Path("filename").resolve())
   | ^^^^^^^^
32 |
33 | os.path.getatime(pathlib.Path("filename"))
   |
help: Replace with `Path.stat(...).st_atime`
   |
30 |
   - getatime(Path("filename").resolve())
31 + Path(Path("filename").resolve()).stat().st_atime
32 |
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:33:1
   |
31 | getatime(Path("filename").resolve())
32 |
33 | os.path.getatime(pathlib.Path("filename"))
   | ^^^^^^^^^^^^^^^^
34 |
35 | getatime(Path("dir") / "file.txt")
   |
help: Replace with `Path.stat(...).st_atime`
   |
32 |
   - os.path.getatime(pathlib.Path("filename"))
33 + pathlib.Path("filename").stat().st_atime
34 |
   |

PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
  --> PTH203.py:35:1
   |
33 | os.path.getatime(pathlib.Path("filename"))
34 |
35 | getatime(Path("dir") / "file.txt")
   | ^^^^^^^^
   |
help: Replace with `Path.stat(...).st_atime`
   |
34 |
   - getatime(Path("dir") / "file.txt")
35 + Path(Path("dir") / "file.txt").stat().st_atime
   |
