[`flake8-use-pathlib`] Add autofixes for `PTH203`, `PTH204`, `PTH205` (#18922)

<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary
Part of #2331 |
[#18763](https://github.com/astral-sh/ruff/pull/18763#issuecomment-2988340436)
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
update snapshots
<!-- How was it tested? -->
This commit is contained in:
chiri 2025-07-07 23:56:21 +03:00 committed by GitHub
parent 47f88b3008
commit e23780c2e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 944 additions and 254 deletions

View File

@ -1,4 +1,4 @@
import os.path
import os.path, pathlib
from pathlib import Path
from os.path import getatime
@ -10,3 +10,26 @@ os.path.getatime(Path("filename"))
getatime("filename")
getatime(b"filename")
getatime(Path("filename"))
file = __file__
os.path.getatime(file)
os.path.getatime(filename="filename")
os.path.getatime(filename=Path("filename"))
os.path.getatime( # comment 1
# comment 2
"filename" # comment 3
# comment 4
, # comment 5
# comment 6
) # comment 7
os.path.getatime("file" + "name")
getatime(Path("filename").resolve())
os.path.getatime(pathlib.Path("filename"))
getatime(Path("dir") / "file.txt")

View File

@ -1062,9 +1062,6 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
Rule::OsPathSplitext,
Rule::BuiltinOpen,
Rule::PyPath,
Rule::OsPathGetatime,
Rule::OsPathGetmtime,
Rule::OsPathGetctime,
Rule::Glob,
Rule::OsListdir,
Rule::OsSymlink,
@ -1074,6 +1071,15 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
if checker.is_rule_enabled(Rule::OsPathGetsize) {
flake8_use_pathlib::rules::os_path_getsize(checker, call);
}
if checker.is_rule_enabled(Rule::OsPathGetatime) {
flake8_use_pathlib::rules::os_path_getatime(checker, call);
}
if checker.is_rule_enabled(Rule::OsPathGetctime) {
flake8_use_pathlib::rules::os_path_getctime(checker, call);
}
if checker.is_rule_enabled(Rule::OsPathGetmtime) {
flake8_use_pathlib::rules::os_path_getmtime(checker, call);
}
if checker.is_rule_enabled(Rule::PathConstructorCurrentDirectory) {
flake8_use_pathlib::rules::path_constructor_current_directory(checker, call);
}

View File

@ -54,6 +54,20 @@ pub(crate) const fn is_fix_manual_list_comprehension_enabled(settings: &LinterSe
pub(crate) const fn is_fix_os_path_getsize_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/18922
pub(crate) const fn is_fix_os_path_getmtime_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/18922
pub(crate) const fn is_fix_os_path_getatime_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/18922
pub(crate) const fn is_fix_os_path_getctime_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/11436
// https://github.com/astral-sh/ruff/pull/11168

View File

@ -0,0 +1,72 @@
use crate::checkers::ast::Checker;
use crate::importer::ImportRequest;
use crate::{Applicability, Edit, Fix, Violation};
use ruff_python_ast::{Expr, ExprCall};
use ruff_text_size::Ranged;
pub(crate) fn is_path_call(checker: &Checker, expr: &Expr) -> bool {
expr.as_call_expr().is_some_and(|expr_call| {
checker
.semantic()
.resolve_qualified_name(&expr_call.func)
.is_some_and(|name| matches!(name.segments(), ["pathlib", "Path"]))
})
}
pub(crate) fn check_os_path_get_calls(
checker: &Checker,
call: &ExprCall,
fn_name: &str,
attr: &str,
fix_enabled: bool,
violation: impl Violation,
) {
if checker
.semantic()
.resolve_qualified_name(&call.func)
.is_none_or(|qualified_name| qualified_name.segments() != ["os", "path", fn_name])
{
return;
}
if call.arguments.len() != 1 {
return;
}
let Some(arg) = call.arguments.find_argument_value("filename", 0) else {
return;
};
let arg_code = checker.locator().slice(arg.range());
let range = call.range();
let mut diagnostic = checker.report_diagnostic(violation, call.func.range());
if fix_enabled {
diagnostic.try_set_fix(|| {
let (import_edit, binding) = checker.importer().get_or_import_symbol(
&ImportRequest::import("pathlib", "Path"),
call.start(),
checker.semantic(),
)?;
let applicability = if checker.comment_ranges().intersects(range) {
Applicability::Unsafe
} else {
Applicability::Safe
};
let replacement = if is_path_call(checker, arg) {
format!("{arg_code}.stat().{attr}")
} else {
format!("{binding}({arg_code}).stat().{attr}")
};
Ok(Fix::applicable_edits(
Edit::range_replacement(replacement, range),
[import_edit],
applicability,
))
});
}
}

View File

@ -1,4 +1,5 @@
//! Rules from [flake8-use-pathlib](https://pypi.org/project/flake8-use-pathlib/).
mod helpers;
pub(crate) mod rules;
pub(crate) mod violations;
@ -81,6 +82,9 @@ mod tests {
#[test_case(Rule::OsPathGetsize, Path::new("PTH202.py"))]
#[test_case(Rule::OsPathGetsize, Path::new("PTH202_2.py"))]
#[test_case(Rule::OsPathGetatime, Path::new("PTH203.py"))]
#[test_case(Rule::OsPathGetmtime, Path::new("PTH204.py"))]
#[test_case(Rule::OsPathGetctime, Path::new("PTH205.py"))]
fn preview_flake8_use_pathlib(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!(
"preview__{}_{}",

View File

@ -1,6 +1,9 @@
use crate::checkers::ast::Checker;
use crate::preview::is_fix_os_path_getatime_enabled;
use crate::rules::flake8_use_pathlib::helpers::check_os_path_get_calls;
use crate::{FixAvailability, Violation};
use ruff_macros::{ViolationMetadata, derive_message_formats};
use crate::Violation;
use ruff_python_ast::ExprCall;
/// ## What it does
/// Checks for uses of `os.path.getatime`.
@ -32,6 +35,9 @@ use crate::Violation;
/// it can be less performant than the lower-level alternatives that work directly with strings,
/// especially on older versions of Python.
///
/// ## Fix Safety
/// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression.
///
/// ## References
/// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat)
/// - [Python documentation: `os.path.getatime`](https://docs.python.org/3/library/os.path.html#os.path.getatime)
@ -43,8 +49,25 @@ use crate::Violation;
pub(crate) struct OsPathGetatime;
impl Violation for OsPathGetatime {
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
#[derive_message_formats]
fn message(&self) -> String {
"`os.path.getatime` should be replaced by `Path.stat().st_atime`".to_string()
}
fn fix_title(&self) -> Option<String> {
Some("Replace with `Path.stat(...).st_atime`".to_string())
}
}
/// PTH203
pub(crate) fn os_path_getatime(checker: &Checker, call: &ExprCall) {
check_os_path_get_calls(
checker,
call,
"getatime",
"st_atime",
is_fix_os_path_getatime_enabled(checker.settings()),
OsPathGetatime,
);
}

View File

@ -1,6 +1,9 @@
use crate::checkers::ast::Checker;
use crate::preview::is_fix_os_path_getctime_enabled;
use crate::rules::flake8_use_pathlib::helpers::check_os_path_get_calls;
use crate::{FixAvailability, Violation};
use ruff_macros::{ViolationMetadata, derive_message_formats};
use crate::Violation;
use ruff_python_ast::ExprCall;
/// ## What it does
/// Checks for uses of `os.path.getctime`.
@ -32,6 +35,9 @@ use crate::Violation;
/// it can be less performant than the lower-level alternatives that work directly with strings,
/// especially on older versions of Python.
///
/// ## Fix Safety
/// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression.
///
/// ## References
/// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat)
/// - [Python documentation: `os.path.getctime`](https://docs.python.org/3/library/os.path.html#os.path.getctime)
@ -43,8 +49,26 @@ use crate::Violation;
pub(crate) struct OsPathGetctime;
impl Violation for OsPathGetctime {
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
#[derive_message_formats]
fn message(&self) -> String {
"`os.path.getctime` should be replaced by `Path.stat().st_ctime`".to_string()
}
fn fix_title(&self) -> Option<String> {
Some("Replace with `Path.stat(...).st_ctime`".to_string())
}
}
/// PTH205
pub(crate) fn os_path_getctime(checker: &Checker, call: &ExprCall) {
check_os_path_get_calls(
checker,
call,
"getctime",
"st_ctime",
is_fix_os_path_getctime_enabled(checker.settings()),
OsPathGetctime,
);
}

View File

@ -1,6 +1,9 @@
use crate::checkers::ast::Checker;
use crate::preview::is_fix_os_path_getmtime_enabled;
use crate::rules::flake8_use_pathlib::helpers::check_os_path_get_calls;
use crate::{FixAvailability, Violation};
use ruff_macros::{ViolationMetadata, derive_message_formats};
use crate::Violation;
use ruff_python_ast::ExprCall;
/// ## What it does
/// Checks for uses of `os.path.getmtime`.
@ -32,6 +35,9 @@ use crate::Violation;
/// it can be less performant than the lower-level alternatives that work directly with strings,
/// especially on older versions of Python.
///
/// ## Fix Safety
/// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression.
///
/// ## References
/// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat)
/// - [Python documentation: `os.path.getmtime`](https://docs.python.org/3/library/os.path.html#os.path.getmtime)
@ -43,8 +49,26 @@ use crate::Violation;
pub(crate) struct OsPathGetmtime;
impl Violation for OsPathGetmtime {
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
#[derive_message_formats]
fn message(&self) -> String {
"`os.path.getmtime` should be replaced by `Path.stat().st_mtime`".to_string()
}
fn fix_title(&self) -> Option<String> {
Some("Replace with `Path.stat(...).st_mtime`".to_string())
}
}
/// PTH204
pub(crate) fn os_path_getmtime(checker: &Checker, call: &ExprCall) {
check_os_path_get_calls(
checker,
call,
"getmtime",
"st_mtime",
is_fix_os_path_getmtime_enabled(checker.settings()),
OsPathGetmtime,
);
}

View File

@ -1,11 +1,9 @@
use crate::checkers::ast::Checker;
use crate::importer::ImportRequest;
use crate::preview::is_fix_os_path_getsize_enabled;
use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
use crate::rules::flake8_use_pathlib::helpers::check_os_path_get_calls;
use crate::{FixAvailability, Violation};
use ruff_macros::{ViolationMetadata, derive_message_formats};
use ruff_python_ast::name::QualifiedName;
use ruff_python_ast::{Expr, ExprCall};
use ruff_text_size::Ranged;
use ruff_python_ast::ExprCall;
/// ## What it does
/// Checks for uses of `os.path.getsize`.
@ -65,63 +63,12 @@ impl Violation for OsPathGetsize {
/// PTH202
pub(crate) fn os_path_getsize(checker: &Checker, call: &ExprCall) {
if !matches!(
checker
.semantic()
.resolve_qualified_name(&call.func)
.as_ref()
.map(QualifiedName::segments),
Some(["os", "path", "getsize"])
) {
return;
}
if call.arguments.len() != 1 {
return;
}
let Some(arg) = call.arguments.find_argument_value("filename", 0) else {
return;
};
let arg_code = checker.locator().slice(arg.range());
let range = call.range();
let applicability = if checker.comment_ranges().intersects(range) {
Applicability::Unsafe
} else {
Applicability::Safe
};
let mut diagnostic = checker.report_diagnostic(OsPathGetsize, range);
if is_fix_os_path_getsize_enabled(checker.settings()) {
diagnostic.try_set_fix(|| {
let (import_edit, binding) = checker.importer().get_or_import_symbol(
&ImportRequest::import("pathlib", "Path"),
call.start(),
checker.semantic(),
)?;
let replacement = if is_path_call(checker, arg) {
format!("{arg_code}.stat().st_size")
} else {
format!("{binding}({arg_code}).stat().st_size")
};
Ok(
Fix::safe_edits(Edit::range_replacement(replacement, range), [import_edit])
.with_applicability(applicability),
)
});
}
}
fn is_path_call(checker: &Checker, expr: &Expr) -> bool {
expr.as_call_expr().is_some_and(|expr_call| {
checker
.semantic()
.resolve_qualified_name(&expr_call.func)
.is_some_and(|name| matches!(name.segments(), ["pathlib", "Path"]))
})
check_os_path_get_calls(
checker,
call,
"getsize",
"st_size",
is_fix_os_path_getsize_enabled(checker.settings()),
OsPathGetsize,
);
}

View File

@ -4,9 +4,7 @@ use ruff_python_semantic::analyze::typing;
use ruff_text_size::Ranged;
use crate::checkers::ast::Checker;
use crate::rules::flake8_use_pathlib::rules::{
Glob, OsPathGetatime, OsPathGetctime, OsPathGetmtime,
};
use crate::rules::flake8_use_pathlib::rules::Glob;
use crate::rules::flake8_use_pathlib::violations::{
BuiltinOpen, Joiner, OsChmod, OsGetcwd, OsListdir, OsMakedirs, OsMkdir, OsPathAbspath,
OsPathBasename, OsPathDirname, OsPathExists, OsPathExpanduser, OsPathIsabs, OsPathIsdir,
@ -194,12 +192,6 @@ pub(crate) fn replaceable_by_pathlib(checker: &Checker, call: &ExprCall) {
["os", "path", "samefile"] => checker.report_diagnostic_if_enabled(OsPathSamefile, range),
// PTH122
["os", "path", "splitext"] => checker.report_diagnostic_if_enabled(OsPathSplitext, range),
// PTH203
["os", "path", "getatime"] => checker.report_diagnostic_if_enabled(OsPathGetatime, range),
// PTH204
["os", "path", "getmtime"] => checker.report_diagnostic_if_enabled(OsPathGetmtime, range),
// PTH205
["os", "path", "getctime"] => checker.report_diagnostic_if_enabled(OsPathGetctime, range),
// PTH211
["os", "symlink"] => {
// `dir_fd` is not supported by pathlib, so check if there are non-default values.

View File

@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
PTH202.py:10:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size`
|
10 | os.path.getsize("filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
|
@ -14,7 +14,7 @@ PTH202.py:11:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
10 | os.path.getsize("filename")
11 | os.path.getsize(b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
12 | os.path.getsize(Path("filename"))
13 | os.path.getsize(__file__)
|
@ -25,7 +25,7 @@ PTH202.py:12:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
10 | os.path.getsize("filename")
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
13 | os.path.getsize(__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -35,7 +35,7 @@ PTH202.py:13:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
13 | os.path.getsize(__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
14 |
15 | os.path.getsize(filename)
|
@ -46,7 +46,7 @@ PTH202.py:15:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
13 | os.path.getsize(__file__)
14 |
15 | os.path.getsize(filename)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
16 | os.path.getsize(filename1)
17 | os.path.getsize(filename2)
|
@ -56,7 +56,7 @@ PTH202.py:16:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
15 | os.path.getsize(filename)
16 | os.path.getsize(filename1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
17 | os.path.getsize(filename2)
|
= help: Replace with `Path(...).stat().st_size`
@ -66,7 +66,7 @@ PTH202.py:17:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
15 | os.path.getsize(filename)
16 | os.path.getsize(filename1)
17 | os.path.getsize(filename2)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
18 |
19 | os.path.getsize(filename="filename")
|
@ -77,7 +77,7 @@ PTH202.py:19:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
17 | os.path.getsize(filename2)
18 |
19 | os.path.getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
|
@ -87,7 +87,7 @@ PTH202.py:20:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
19 | os.path.getsize(filename="filename")
20 | os.path.getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
21 | os.path.getsize(filename=Path("filename"))
22 | os.path.getsize(filename=__file__)
|
@ -98,7 +98,7 @@ PTH202.py:21:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
19 | os.path.getsize(filename="filename")
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
22 | os.path.getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -108,7 +108,7 @@ PTH202.py:22:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
22 | os.path.getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
23 |
24 | getsize("filename")
|
@ -119,7 +119,7 @@ PTH202.py:24:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
22 | os.path.getsize(filename=__file__)
23 |
24 | getsize("filename")
| ^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
25 | getsize(b"filename")
26 | getsize(Path("filename"))
|
@ -129,7 +129,7 @@ PTH202.py:25:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
24 | getsize("filename")
25 | getsize(b"filename")
| ^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
26 | getsize(Path("filename"))
27 | getsize(__file__)
|
@ -140,7 +140,7 @@ PTH202.py:26:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
24 | getsize("filename")
25 | getsize(b"filename")
26 | getsize(Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
27 | getsize(__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -150,7 +150,7 @@ PTH202.py:27:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
25 | getsize(b"filename")
26 | getsize(Path("filename"))
27 | getsize(__file__)
| ^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
28 |
29 | getsize(filename="filename")
|
@ -161,7 +161,7 @@ PTH202.py:29:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
27 | getsize(__file__)
28 |
29 | getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
|
@ -171,7 +171,7 @@ PTH202.py:30:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
29 | getsize(filename="filename")
30 | getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
31 | getsize(filename=Path("filename"))
32 | getsize(filename=__file__)
|
@ -182,7 +182,7 @@ PTH202.py:31:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
29 | getsize(filename="filename")
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
32 | getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -192,7 +192,7 @@ PTH202.py:32:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
32 | getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
33 |
34 | getsize(filename)
|
@ -203,7 +203,7 @@ PTH202.py:34:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
32 | getsize(filename=__file__)
33 |
34 | getsize(filename)
| ^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
35 | getsize(filename1)
36 | getsize(filename2)
|
@ -213,7 +213,7 @@ PTH202.py:35:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
34 | getsize(filename)
35 | getsize(filename1)
| ^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
36 | getsize(filename2)
|
= help: Replace with `Path(...).stat().st_size`
@ -223,18 +223,16 @@ PTH202.py:36:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
34 | getsize(filename)
35 | getsize(filename1)
36 | getsize(filename2)
| ^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`
PTH202.py:39:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size`
|
39 | / os.path.getsize(
40 | | "filename", # comment
41 | | )
| |_^ PTH202
42 |
43 | os.path.getsize(
39 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
40 | "filename", # comment
41 | )
|
= help: Replace with `Path(...).stat().st_size`
@ -242,15 +240,10 @@ PTH202.py:43:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
41 | )
42 |
43 | / os.path.getsize(
44 | | # comment
45 | | "filename"
46 | | ,
47 | | # comment
48 | | )
| |_^ PTH202
49 |
50 | os.path.getsize(
43 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
44 | # comment
45 | "filename"
|
= help: Replace with `Path(...).stat().st_size`
@ -258,14 +251,10 @@ PTH202.py:50:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
48 | )
49 |
50 | / os.path.getsize(
51 | | # comment
52 | | b"filename"
53 | | # comment
54 | | )
| |_^ PTH202
55 |
56 | os.path.getsize( # comment
50 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
51 | # comment
52 | b"filename"
|
= help: Replace with `Path(...).stat().st_size`
@ -273,13 +262,10 @@ PTH202.py:56:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
54 | )
55 |
56 | / os.path.getsize( # comment
57 | | Path(__file__)
58 | | # comment
59 | | ) # comment
| |_^ PTH202
60 |
61 | getsize( # comment
56 | os.path.getsize( # comment
| ^^^^^^^^^^^^^^^ PTH202
57 | Path(__file__)
58 | # comment
|
= help: Replace with `Path(...).stat().st_size`
@ -287,11 +273,9 @@ PTH202.py:61:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
59 | ) # comment
60 |
61 | / getsize( # comment
62 | | "filename")
| |_______________^ PTH202
63 |
64 | getsize( # comment
61 | getsize( # comment
| ^^^^^^^ PTH202
62 | "filename")
|
= help: Replace with `Path(...).stat().st_size`
@ -299,13 +283,10 @@ PTH202.py:64:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
62 | "filename")
63 |
64 | / getsize( # comment
65 | | b"filename",
66 | | #comment
67 | | )
| |_^ PTH202
68 |
69 | os.path.getsize("file" + "name")
64 | getsize( # comment
| ^^^^^^^ PTH202
65 | b"filename",
66 | #comment
|
= help: Replace with `Path(...).stat().st_size`
@ -314,7 +295,7 @@ PTH202.py:69:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
67 | )
68 |
69 | os.path.getsize("file" + "name")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
70 |
71 | getsize \
|
@ -324,15 +305,10 @@ PTH202.py:71:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
|
69 | os.path.getsize("file" + "name")
70 |
71 | / getsize \
72 | | \
73 | | \
74 | | ( # comment
75 | | "filename",
76 | | )
| |_____^ PTH202
77 |
78 | getsize(Path("filename").resolve())
71 | getsize \
| ^^^^^^^ PTH202
72 | \
73 | \
|
= help: Replace with `Path(...).stat().st_size`
@ -341,7 +317,7 @@ PTH202.py:78:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
76 | )
77 |
78 | getsize(Path("filename").resolve())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
79 |
80 | import pathlib
|
@ -352,6 +328,6 @@ PTH202.py:82:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_s
80 | import pathlib
81 |
82 | os.path.getsize(pathlib.Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`

View File

@ -6,7 +6,7 @@ PTH202_2.py:3:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_
1 | import os
2 |
3 | os.path.getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
4 | os.path.getsize(filename=b"filename")
5 | os.path.getsize(filename=__file__)
|
@ -16,7 +16,7 @@ PTH202_2.py:4:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_
|
3 | os.path.getsize(filename="filename")
4 | os.path.getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
5 | os.path.getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -26,6 +26,6 @@ PTH202_2.py:5:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_
3 | os.path.getsize(filename="filename")
4 | os.path.getsize(filename=b"filename")
5 | os.path.getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`

View File

@ -10,6 +10,7 @@ PTH203.py:5:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_a
6 | os.path.getatime(b"filename")
7 | os.path.getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:6:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
@ -18,6 +19,7 @@ PTH203.py:6:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_a
| ^^^^^^^^^^^^^^^^ PTH203
7 | os.path.getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:7:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
@ -26,6 +28,7 @@ PTH203.py:7:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_a
7 | os.path.getatime(Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:10:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
@ -34,6 +37,7 @@ PTH203.py:10:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_
11 | getatime(b"filename")
12 | getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:11:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
@ -42,6 +46,7 @@ PTH203.py:11:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_
| ^^^^^^^^ PTH203
12 | getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:12:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
@ -50,3 +55,88 @@ PTH203.py:12:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_
12 | getatime(Path("filename"))
| ^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:17:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
15 | file = __file__
16 |
17 | os.path.getatime(file)
| ^^^^^^^^^^^^^^^^ PTH203
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:18:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
| ^^^^^^^^^^^^^^^^ PTH203
19 | os.path.getatime(filename=Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:19:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
20 |
21 | os.path.getatime( # comment 1
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:21:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
19 | os.path.getatime(filename=Path("filename"))
20 |
21 | os.path.getatime( # comment 1
| ^^^^^^^^^^^^^^^^ PTH203
22 | # comment 2
23 | "filename" # comment 3
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:29:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
27 | ) # comment 7
28 |
29 | os.path.getatime("file" + "name")
| ^^^^^^^^^^^^^^^^ PTH203
30 |
31 | getatime(Path("filename").resolve())
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:31:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
29 | os.path.getatime("file" + "name")
30 |
31 | getatime(Path("filename").resolve())
| ^^^^^^^^ PTH203
32 |
33 | os.path.getatime(pathlib.Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:33:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
31 | getatime(Path("filename").resolve())
32 |
33 | os.path.getatime(pathlib.Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
34 |
35 | getatime(Path("dir") / "file.txt")
|
= help: Replace with `Path.stat(...).st_atime`
PTH203.py:35:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
33 | os.path.getatime(pathlib.Path("filename"))
34 |
35 | getatime(Path("dir") / "file.txt")
| ^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`

View File

@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
snapshot_kind: text
---
PTH204.py:6:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -9,6 +8,7 @@ PTH204.py:6:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_m
7 | os.path.getmtime(b"filename")
8 | os.path.getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
PTH204.py:7:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -17,6 +17,7 @@ PTH204.py:7:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_m
| ^^^^^^^^^^^^^^^^ PTH204
8 | os.path.getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
PTH204.py:8:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -25,6 +26,7 @@ PTH204.py:8:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_m
8 | os.path.getmtime(Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH204
|
= help: Replace with `Path.stat(...).st_mtime`
PTH204.py:11:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -33,6 +35,7 @@ PTH204.py:11:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_
12 | getmtime(b"filename")
13 | getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
PTH204.py:12:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -41,6 +44,7 @@ PTH204.py:12:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_
| ^^^^^^^^ PTH204
13 | getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
PTH204.py:13:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
@ -49,3 +53,4 @@ PTH204.py:13:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_
13 | getmtime(Path("filename"))
| ^^^^^^^^ PTH204
|
= help: Replace with `Path.stat(...).st_mtime`

View File

@ -8,6 +8,7 @@ PTH205.py:6:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_c
7 | os.path.getctime(b"filename")
8 | os.path.getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
PTH205.py:7:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
@ -16,6 +17,7 @@ PTH205.py:7:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_c
| ^^^^^^^^^^^^^^^^ PTH205
8 | os.path.getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
@ -26,6 +28,7 @@ PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_c
9 |
10 | getctime("filename")
|
= help: Replace with `Path.stat(...).st_ctime`
PTH205.py:10:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
@ -36,6 +39,7 @@ PTH205.py:10:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_
11 | getctime(b"filename")
12 | getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
PTH205.py:11:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
@ -44,6 +48,7 @@ PTH205.py:11:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_
| ^^^^^^^^ PTH205
12 | getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
PTH205.py:12:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
@ -52,3 +57,4 @@ PTH205.py:12:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_
12 | getctime(Path("filename"))
| ^^^^^^^^ PTH205
|
= help: Replace with `Path.stat(...).st_ctime`

View File

@ -4,7 +4,7 @@ source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
PTH202.py:10:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size`
|
10 | os.path.getsize("filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
|
@ -24,7 +24,7 @@ PTH202.py:11:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
10 | os.path.getsize("filename")
11 | os.path.getsize(b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
12 | os.path.getsize(Path("filename"))
13 | os.path.getsize(__file__)
|
@ -45,7 +45,7 @@ PTH202.py:12:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
10 | os.path.getsize("filename")
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
13 | os.path.getsize(__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -65,7 +65,7 @@ PTH202.py:13:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
11 | os.path.getsize(b"filename")
12 | os.path.getsize(Path("filename"))
13 | os.path.getsize(__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
14 |
15 | os.path.getsize(filename)
|
@ -86,7 +86,7 @@ PTH202.py:15:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
13 | os.path.getsize(__file__)
14 |
15 | os.path.getsize(filename)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
16 | os.path.getsize(filename1)
17 | os.path.getsize(filename2)
|
@ -106,7 +106,7 @@ PTH202.py:16:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
15 | os.path.getsize(filename)
16 | os.path.getsize(filename1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
17 | os.path.getsize(filename2)
|
= help: Replace with `Path(...).stat().st_size`
@ -126,7 +126,7 @@ PTH202.py:17:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
15 | os.path.getsize(filename)
16 | os.path.getsize(filename1)
17 | os.path.getsize(filename2)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
18 |
19 | os.path.getsize(filename="filename")
|
@ -147,7 +147,7 @@ PTH202.py:19:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
17 | os.path.getsize(filename2)
18 |
19 | os.path.getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
|
@ -167,7 +167,7 @@ PTH202.py:20:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
19 | os.path.getsize(filename="filename")
20 | os.path.getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
21 | os.path.getsize(filename=Path("filename"))
22 | os.path.getsize(filename=__file__)
|
@ -188,7 +188,7 @@ PTH202.py:21:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
19 | os.path.getsize(filename="filename")
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
22 | os.path.getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -208,7 +208,7 @@ PTH202.py:22:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
20 | os.path.getsize(filename=b"filename")
21 | os.path.getsize(filename=Path("filename"))
22 | os.path.getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
23 |
24 | getsize("filename")
|
@ -229,7 +229,7 @@ PTH202.py:24:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
22 | os.path.getsize(filename=__file__)
23 |
24 | getsize("filename")
| ^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
25 | getsize(b"filename")
26 | getsize(Path("filename"))
|
@ -249,7 +249,7 @@ PTH202.py:25:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
24 | getsize("filename")
25 | getsize(b"filename")
| ^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
26 | getsize(Path("filename"))
27 | getsize(__file__)
|
@ -270,7 +270,7 @@ PTH202.py:26:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
24 | getsize("filename")
25 | getsize(b"filename")
26 | getsize(Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
27 | getsize(__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -290,7 +290,7 @@ PTH202.py:27:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
25 | getsize(b"filename")
26 | getsize(Path("filename"))
27 | getsize(__file__)
| ^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
28 |
29 | getsize(filename="filename")
|
@ -311,7 +311,7 @@ PTH202.py:29:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
27 | getsize(__file__)
28 |
29 | getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
|
@ -331,7 +331,7 @@ PTH202.py:30:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
29 | getsize(filename="filename")
30 | getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
31 | getsize(filename=Path("filename"))
32 | getsize(filename=__file__)
|
@ -352,7 +352,7 @@ PTH202.py:31:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
29 | getsize(filename="filename")
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
32 | getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -372,7 +372,7 @@ PTH202.py:32:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
30 | getsize(filename=b"filename")
31 | getsize(filename=Path("filename"))
32 | getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
33 |
34 | getsize(filename)
|
@ -393,7 +393,7 @@ PTH202.py:34:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
32 | getsize(filename=__file__)
33 |
34 | getsize(filename)
| ^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
35 | getsize(filename1)
36 | getsize(filename2)
|
@ -413,7 +413,7 @@ PTH202.py:35:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
34 | getsize(filename)
35 | getsize(filename1)
| ^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
36 | getsize(filename2)
|
= help: Replace with `Path(...).stat().st_size`
@ -433,7 +433,7 @@ PTH202.py:36:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
34 | getsize(filename)
35 | getsize(filename1)
36 | getsize(filename2)
| ^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`
@ -449,12 +449,10 @@ PTH202.py:36:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
PTH202.py:39:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size`
|
39 | / os.path.getsize(
40 | | "filename", # comment
41 | | )
| |_^ PTH202
42 |
43 | os.path.getsize(
39 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
40 | "filename", # comment
41 | )
|
= help: Replace with `Path(...).stat().st_size`
@ -474,15 +472,10 @@ PTH202.py:43:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
41 | )
42 |
43 | / os.path.getsize(
44 | | # comment
45 | | "filename"
46 | | ,
47 | | # comment
48 | | )
| |_^ PTH202
49 |
50 | os.path.getsize(
43 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
44 | # comment
45 | "filename"
|
= help: Replace with `Path(...).stat().st_size`
@ -505,14 +498,10 @@ PTH202.py:50:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
48 | )
49 |
50 | / os.path.getsize(
51 | | # comment
52 | | b"filename"
53 | | # comment
54 | | )
| |_^ PTH202
55 |
56 | os.path.getsize( # comment
50 | os.path.getsize(
| ^^^^^^^^^^^^^^^ PTH202
51 | # comment
52 | b"filename"
|
= help: Replace with `Path(...).stat().st_size`
@ -534,13 +523,10 @@ PTH202.py:56:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
54 | )
55 |
56 | / os.path.getsize( # comment
57 | | Path(__file__)
58 | | # comment
59 | | ) # comment
| |_^ PTH202
60 |
61 | getsize( # comment
56 | os.path.getsize( # comment
| ^^^^^^^^^^^^^^^ PTH202
57 | Path(__file__)
58 | # comment
|
= help: Replace with `Path(...).stat().st_size`
@ -561,11 +547,9 @@ PTH202.py:61:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
59 | ) # comment
60 |
61 | / getsize( # comment
62 | | "filename")
| |_______________^ PTH202
63 |
64 | getsize( # comment
61 | getsize( # comment
| ^^^^^^^ PTH202
62 | "filename")
|
= help: Replace with `Path(...).stat().st_size`
@ -584,13 +568,10 @@ PTH202.py:64:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
62 | "filename")
63 |
64 | / getsize( # comment
65 | | b"filename",
66 | | #comment
67 | | )
| |_^ PTH202
68 |
69 | os.path.getsize("file" + "name")
64 | getsize( # comment
| ^^^^^^^ PTH202
65 | b"filename",
66 | #comment
|
= help: Replace with `Path(...).stat().st_size`
@ -612,7 +593,7 @@ PTH202.py:69:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
67 | )
68 |
69 | os.path.getsize("file" + "name")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
70 |
71 | getsize \
|
@ -632,15 +613,10 @@ PTH202.py:71:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
|
69 | os.path.getsize("file" + "name")
70 |
71 | / getsize \
72 | | \
73 | | \
74 | | ( # comment
75 | | "filename",
76 | | )
| |_____^ PTH202
77 |
78 | getsize(Path("filename").resolve())
71 | getsize \
| ^^^^^^^ PTH202
72 | \
73 | \
|
= help: Replace with `Path(...).stat().st_size`
@ -664,7 +640,7 @@ PTH202.py:78:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
76 | )
77 |
78 | getsize(Path("filename").resolve())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^ PTH202
79 |
80 | import pathlib
|
@ -685,7 +661,7 @@ PTH202.py:82:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().
80 | import pathlib
81 |
82 | os.path.getsize(pathlib.Path("filename"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`

View File

@ -6,7 +6,7 @@ PTH202_2.py:3:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat()
1 | import os
2 |
3 | os.path.getsize(filename="filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
4 | os.path.getsize(filename=b"filename")
5 | os.path.getsize(filename=__file__)
|
@ -25,7 +25,7 @@ PTH202_2.py:4:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat()
|
3 | os.path.getsize(filename="filename")
4 | os.path.getsize(filename=b"filename")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
5 | os.path.getsize(filename=__file__)
|
= help: Replace with `Path(...).stat().st_size`
@ -44,7 +44,7 @@ PTH202_2.py:5:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat()
3 | os.path.getsize(filename="filename")
4 | os.path.getsize(filename=b"filename")
5 | os.path.getsize(filename=__file__)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH202
| ^^^^^^^^^^^^^^^ PTH202
|
= help: Replace with `Path(...).stat().st_size`

View File

@ -0,0 +1,284 @@
---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH203.py:5:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
3 | from os.path import getatime
4 |
5 | os.path.getatime("filename")
| ^^^^^^^^^^^^^^^^ PTH203
6 | os.path.getatime(b"filename")
7 | os.path.getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
2 2 | from pathlib import Path
3 3 | from os.path import getatime
4 4 |
5 |-os.path.getatime("filename")
5 |+Path("filename").stat().st_atime
6 6 | os.path.getatime(b"filename")
7 7 | os.path.getatime(Path("filename"))
8 8 |
PTH203.py:6:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
5 | os.path.getatime("filename")
6 | os.path.getatime(b"filename")
| ^^^^^^^^^^^^^^^^ PTH203
7 | os.path.getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
3 3 | from os.path import getatime
4 4 |
5 5 | os.path.getatime("filename")
6 |-os.path.getatime(b"filename")
6 |+Path(b"filename").stat().st_atime
7 7 | os.path.getatime(Path("filename"))
8 8 |
9 9 |
PTH203.py:7:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
5 | os.path.getatime("filename")
6 | os.path.getatime(b"filename")
7 | os.path.getatime(Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
4 4 |
5 5 | os.path.getatime("filename")
6 6 | os.path.getatime(b"filename")
7 |-os.path.getatime(Path("filename"))
7 |+Path("filename").stat().st_atime
8 8 |
9 9 |
10 10 | getatime("filename")
PTH203.py:10:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
10 | getatime("filename")
| ^^^^^^^^ PTH203
11 | getatime(b"filename")
12 | getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
7 7 | os.path.getatime(Path("filename"))
8 8 |
9 9 |
10 |-getatime("filename")
10 |+Path("filename").stat().st_atime
11 11 | getatime(b"filename")
12 12 | getatime(Path("filename"))
13 13 |
PTH203.py:11:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
10 | getatime("filename")
11 | getatime(b"filename")
| ^^^^^^^^ PTH203
12 | getatime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
8 8 |
9 9 |
10 10 | getatime("filename")
11 |-getatime(b"filename")
11 |+Path(b"filename").stat().st_atime
12 12 | getatime(Path("filename"))
13 13 |
14 14 |
PTH203.py:12:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
10 | getatime("filename")
11 | getatime(b"filename")
12 | getatime(Path("filename"))
| ^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
9 9 |
10 10 | getatime("filename")
11 11 | getatime(b"filename")
12 |-getatime(Path("filename"))
12 |+Path("filename").stat().st_atime
13 13 |
14 14 |
15 15 | file = __file__
PTH203.py:17:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
15 | file = __file__
16 |
17 | os.path.getatime(file)
| ^^^^^^^^^^^^^^^^ PTH203
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
14 14 |
15 15 | file = __file__
16 16 |
17 |-os.path.getatime(file)
17 |+Path(file).stat().st_atime
18 18 | os.path.getatime(filename="filename")
19 19 | os.path.getatime(filename=Path("filename"))
20 20 |
PTH203.py:18:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
| ^^^^^^^^^^^^^^^^ PTH203
19 | os.path.getatime(filename=Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
15 15 | file = __file__
16 16 |
17 17 | os.path.getatime(file)
18 |-os.path.getatime(filename="filename")
18 |+Path("filename").stat().st_atime
19 19 | os.path.getatime(filename=Path("filename"))
20 20 |
21 21 | os.path.getatime( # comment 1
PTH203.py:19:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
17 | os.path.getatime(file)
18 | os.path.getatime(filename="filename")
19 | os.path.getatime(filename=Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
20 |
21 | os.path.getatime( # comment 1
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
16 16 |
17 17 | os.path.getatime(file)
18 18 | os.path.getatime(filename="filename")
19 |-os.path.getatime(filename=Path("filename"))
19 |+Path("filename").stat().st_atime
20 20 |
21 21 | os.path.getatime( # comment 1
22 22 | # comment 2
PTH203.py:21:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
19 | os.path.getatime(filename=Path("filename"))
20 |
21 | os.path.getatime( # comment 1
| ^^^^^^^^^^^^^^^^ PTH203
22 | # comment 2
23 | "filename" # comment 3
|
= help: Replace with `Path.stat(...).st_atime`
Unsafe fix
18 18 | os.path.getatime(filename="filename")
19 19 | os.path.getatime(filename=Path("filename"))
20 20 |
21 |-os.path.getatime( # comment 1
22 |- # comment 2
23 |- "filename" # comment 3
24 |- # comment 4
25 |- , # comment 5
26 |- # comment 6
27 |-) # comment 7
21 |+Path("filename").stat().st_atime # comment 7
28 22 |
29 23 | os.path.getatime("file" + "name")
30 24 |
PTH203.py:29:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
27 | ) # comment 7
28 |
29 | os.path.getatime("file" + "name")
| ^^^^^^^^^^^^^^^^ PTH203
30 |
31 | getatime(Path("filename").resolve())
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
26 26 | # comment 6
27 27 | ) # comment 7
28 28 |
29 |-os.path.getatime("file" + "name")
29 |+Path("file" + "name").stat().st_atime
30 30 |
31 31 | getatime(Path("filename").resolve())
32 32 |
PTH203.py:31:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
29 | os.path.getatime("file" + "name")
30 |
31 | getatime(Path("filename").resolve())
| ^^^^^^^^ PTH203
32 |
33 | os.path.getatime(pathlib.Path("filename"))
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
28 28 |
29 29 | os.path.getatime("file" + "name")
30 30 |
31 |-getatime(Path("filename").resolve())
31 |+Path(Path("filename").resolve()).stat().st_atime
32 32 |
33 33 | os.path.getatime(pathlib.Path("filename"))
34 34 |
PTH203.py:33:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
31 | getatime(Path("filename").resolve())
32 |
33 | os.path.getatime(pathlib.Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH203
34 |
35 | getatime(Path("dir") / "file.txt")
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
30 30 |
31 31 | getatime(Path("filename").resolve())
32 32 |
33 |-os.path.getatime(pathlib.Path("filename"))
33 |+pathlib.Path("filename").stat().st_atime
34 34 |
35 35 | getatime(Path("dir") / "file.txt")
PTH203.py:35:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime`
|
33 | os.path.getatime(pathlib.Path("filename"))
34 |
35 | getatime(Path("dir") / "file.txt")
| ^^^^^^^^ PTH203
|
= help: Replace with `Path.stat(...).st_atime`
Safe fix
32 32 |
33 33 | os.path.getatime(pathlib.Path("filename"))
34 34 |
35 |-getatime(Path("dir") / "file.txt")
35 |+Path(Path("dir") / "file.txt").stat().st_atime

View File

@ -0,0 +1,110 @@
---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH204.py:6:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
6 | os.path.getmtime("filename")
| ^^^^^^^^^^^^^^^^ PTH204
7 | os.path.getmtime(b"filename")
8 | os.path.getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
3 3 | from os.path import getmtime
4 4 |
5 5 |
6 |-os.path.getmtime("filename")
6 |+Path("filename").stat().st_mtime
7 7 | os.path.getmtime(b"filename")
8 8 | os.path.getmtime(Path("filename"))
9 9 |
PTH204.py:7:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
6 | os.path.getmtime("filename")
7 | os.path.getmtime(b"filename")
| ^^^^^^^^^^^^^^^^ PTH204
8 | os.path.getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
4 4 |
5 5 |
6 6 | os.path.getmtime("filename")
7 |-os.path.getmtime(b"filename")
7 |+Path(b"filename").stat().st_mtime
8 8 | os.path.getmtime(Path("filename"))
9 9 |
10 10 |
PTH204.py:8:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
6 | os.path.getmtime("filename")
7 | os.path.getmtime(b"filename")
8 | os.path.getmtime(Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH204
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
5 5 |
6 6 | os.path.getmtime("filename")
7 7 | os.path.getmtime(b"filename")
8 |-os.path.getmtime(Path("filename"))
8 |+Path("filename").stat().st_mtime
9 9 |
10 10 |
11 11 | getmtime("filename")
PTH204.py:11:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
11 | getmtime("filename")
| ^^^^^^^^ PTH204
12 | getmtime(b"filename")
13 | getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
8 8 | os.path.getmtime(Path("filename"))
9 9 |
10 10 |
11 |-getmtime("filename")
11 |+Path("filename").stat().st_mtime
12 12 | getmtime(b"filename")
13 13 | getmtime(Path("filename"))
PTH204.py:12:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
11 | getmtime("filename")
12 | getmtime(b"filename")
| ^^^^^^^^ PTH204
13 | getmtime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
9 9 |
10 10 |
11 11 | getmtime("filename")
12 |-getmtime(b"filename")
12 |+Path(b"filename").stat().st_mtime
13 13 | getmtime(Path("filename"))
PTH204.py:13:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
|
11 | getmtime("filename")
12 | getmtime(b"filename")
13 | getmtime(Path("filename"))
| ^^^^^^^^ PTH204
|
= help: Replace with `Path.stat(...).st_mtime`
Safe fix
10 10 |
11 11 | getmtime("filename")
12 12 | getmtime(b"filename")
13 |-getmtime(Path("filename"))
13 |+Path("filename").stat().st_mtime

View File

@ -0,0 +1,114 @@
---
source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs
---
PTH205.py:6:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
6 | os.path.getctime("filename")
| ^^^^^^^^^^^^^^^^ PTH205
7 | os.path.getctime(b"filename")
8 | os.path.getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
3 3 | from os.path import getctime
4 4 |
5 5 |
6 |-os.path.getctime("filename")
6 |+Path("filename").stat().st_ctime
7 7 | os.path.getctime(b"filename")
8 8 | os.path.getctime(Path("filename"))
9 9 |
PTH205.py:7:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
6 | os.path.getctime("filename")
7 | os.path.getctime(b"filename")
| ^^^^^^^^^^^^^^^^ PTH205
8 | os.path.getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
4 4 |
5 5 |
6 6 | os.path.getctime("filename")
7 |-os.path.getctime(b"filename")
7 |+Path(b"filename").stat().st_ctime
8 8 | os.path.getctime(Path("filename"))
9 9 |
10 10 | getctime("filename")
PTH205.py:8:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
6 | os.path.getctime("filename")
7 | os.path.getctime(b"filename")
8 | os.path.getctime(Path("filename"))
| ^^^^^^^^^^^^^^^^ PTH205
9 |
10 | getctime("filename")
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
5 5 |
6 6 | os.path.getctime("filename")
7 7 | os.path.getctime(b"filename")
8 |-os.path.getctime(Path("filename"))
8 |+Path("filename").stat().st_ctime
9 9 |
10 10 | getctime("filename")
11 11 | getctime(b"filename")
PTH205.py:10:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
8 | os.path.getctime(Path("filename"))
9 |
10 | getctime("filename")
| ^^^^^^^^ PTH205
11 | getctime(b"filename")
12 | getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
7 7 | os.path.getctime(b"filename")
8 8 | os.path.getctime(Path("filename"))
9 9 |
10 |-getctime("filename")
10 |+Path("filename").stat().st_ctime
11 11 | getctime(b"filename")
12 12 | getctime(Path("filename"))
PTH205.py:11:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
10 | getctime("filename")
11 | getctime(b"filename")
| ^^^^^^^^ PTH205
12 | getctime(Path("filename"))
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
8 8 | os.path.getctime(Path("filename"))
9 9 |
10 10 | getctime("filename")
11 |-getctime(b"filename")
11 |+Path(b"filename").stat().st_ctime
12 12 | getctime(Path("filename"))
PTH205.py:12:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime`
|
10 | getctime("filename")
11 | getctime(b"filename")
12 | getctime(Path("filename"))
| ^^^^^^^^ PTH205
|
= help: Replace with `Path.stat(...).st_ctime`
Safe fix
9 9 |
10 10 | getctime("filename")
11 11 | getctime(b"filename")
12 |-getctime(Path("filename"))
12 |+Path("filename").stat().st_ctime