Rename `pathlib` rules to match updated naming convention (#3660)

This commit is contained in:
Charlie Marsh 2023-03-22 11:35:45 -04:00 committed by GitHub
parent 3ec1ea8ac2
commit 875f61cb62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 268 additions and 269 deletions

View File

@ -2886,30 +2886,30 @@ where
// flake8-use-pathlib // flake8-use-pathlib
if self.settings.rules.any_enabled(&[ if self.settings.rules.any_enabled(&[
Rule::PathlibAbspath, Rule::OsPathAbspath,
Rule::PathlibChmod, Rule::OsChmod,
Rule::PathlibMkdir, Rule::OsMkdir,
Rule::PathlibMakedirs, Rule::OsMakedirs,
Rule::PathlibRename, Rule::OsRename,
Rule::PathlibReplace, Rule::PathlibReplace,
Rule::PathlibRmdir, Rule::OsRmdir,
Rule::PathlibRemove, Rule::OsRemove,
Rule::PathlibUnlink, Rule::OsUnlink,
Rule::PathlibGetcwd, Rule::OsGetcwd,
Rule::PathlibExists, Rule::OsPathExists,
Rule::PathlibExpanduser, Rule::OsPathExpanduser,
Rule::PathlibIsDir, Rule::OsPathIsdir,
Rule::PathlibIsFile, Rule::OsPathIsfile,
Rule::PathlibIsLink, Rule::OsPathIslink,
Rule::PathlibReadlink, Rule::OsReadlink,
Rule::PathlibStat, Rule::OsStat,
Rule::PathlibIsAbs, Rule::OsPathIsabs,
Rule::PathlibJoin, Rule::OsPathJoin,
Rule::PathlibBasename, Rule::OsPathBasename,
Rule::PathlibSamefile, Rule::OsPathSamefile,
Rule::PathlibSplitext, Rule::OsPathSplitext,
Rule::PathlibOpen, Rule::BuiltinOpen,
Rule::PathlibPyPath, Rule::PyPath,
]) { ]) {
flake8_use_pathlib::helpers::replaceable_by_pathlib(self, func); flake8_use_pathlib::helpers::replaceable_by_pathlib(self, func);
} }

View File

@ -638,31 +638,31 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<Rule> {
(Tryceratops, "401") => Rule::VerboseLogMessage, (Tryceratops, "401") => Rule::VerboseLogMessage,
// flake8-use-pathlib // flake8-use-pathlib
(Flake8UsePathlib, "100") => Rule::PathlibAbspath, (Flake8UsePathlib, "100") => Rule::OsPathAbspath,
(Flake8UsePathlib, "101") => Rule::PathlibChmod, (Flake8UsePathlib, "101") => Rule::OsChmod,
(Flake8UsePathlib, "102") => Rule::PathlibMkdir, (Flake8UsePathlib, "102") => Rule::OsMkdir,
(Flake8UsePathlib, "103") => Rule::PathlibMakedirs, (Flake8UsePathlib, "103") => Rule::OsMakedirs,
(Flake8UsePathlib, "104") => Rule::PathlibRename, (Flake8UsePathlib, "104") => Rule::OsRename,
(Flake8UsePathlib, "105") => Rule::PathlibReplace, (Flake8UsePathlib, "105") => Rule::PathlibReplace,
(Flake8UsePathlib, "106") => Rule::PathlibRmdir, (Flake8UsePathlib, "106") => Rule::OsRmdir,
(Flake8UsePathlib, "107") => Rule::PathlibRemove, (Flake8UsePathlib, "107") => Rule::OsRemove,
(Flake8UsePathlib, "108") => Rule::PathlibUnlink, (Flake8UsePathlib, "108") => Rule::OsUnlink,
(Flake8UsePathlib, "109") => Rule::PathlibGetcwd, (Flake8UsePathlib, "109") => Rule::OsGetcwd,
(Flake8UsePathlib, "110") => Rule::PathlibExists, (Flake8UsePathlib, "110") => Rule::OsPathExists,
(Flake8UsePathlib, "111") => Rule::PathlibExpanduser, (Flake8UsePathlib, "111") => Rule::OsPathExpanduser,
(Flake8UsePathlib, "112") => Rule::PathlibIsDir, (Flake8UsePathlib, "112") => Rule::OsPathIsdir,
(Flake8UsePathlib, "113") => Rule::PathlibIsFile, (Flake8UsePathlib, "113") => Rule::OsPathIsfile,
(Flake8UsePathlib, "114") => Rule::PathlibIsLink, (Flake8UsePathlib, "114") => Rule::OsPathIslink,
(Flake8UsePathlib, "115") => Rule::PathlibReadlink, (Flake8UsePathlib, "115") => Rule::OsReadlink,
(Flake8UsePathlib, "116") => Rule::PathlibStat, (Flake8UsePathlib, "116") => Rule::OsStat,
(Flake8UsePathlib, "117") => Rule::PathlibIsAbs, (Flake8UsePathlib, "117") => Rule::OsPathIsabs,
(Flake8UsePathlib, "118") => Rule::PathlibJoin, (Flake8UsePathlib, "118") => Rule::OsPathJoin,
(Flake8UsePathlib, "119") => Rule::PathlibBasename, (Flake8UsePathlib, "119") => Rule::OsPathBasename,
(Flake8UsePathlib, "120") => Rule::PathlibDirname, (Flake8UsePathlib, "120") => Rule::OsPathDirname,
(Flake8UsePathlib, "121") => Rule::PathlibSamefile, (Flake8UsePathlib, "121") => Rule::OsPathSamefile,
(Flake8UsePathlib, "122") => Rule::PathlibSplitext, (Flake8UsePathlib, "122") => Rule::OsPathSplitext,
(Flake8UsePathlib, "123") => Rule::PathlibOpen, (Flake8UsePathlib, "123") => Rule::BuiltinOpen,
(Flake8UsePathlib, "124") => Rule::PathlibPyPath, (Flake8UsePathlib, "124") => Rule::PyPath,
// flake8-logging-format // flake8-logging-format
(Flake8LoggingFormat, "001") => Rule::LoggingStringFormat, (Flake8LoggingFormat, "001") => Rule::LoggingStringFormat,

View File

@ -587,31 +587,31 @@ ruff_macros::register_rules!(
rules::tryceratops::rules::ErrorInsteadOfException, rules::tryceratops::rules::ErrorInsteadOfException,
rules::tryceratops::rules::VerboseLogMessage, rules::tryceratops::rules::VerboseLogMessage,
// flake8-use-pathlib // flake8-use-pathlib
rules::flake8_use_pathlib::violations::PathlibAbspath, rules::flake8_use_pathlib::violations::OsPathAbspath,
rules::flake8_use_pathlib::violations::PathlibChmod, rules::flake8_use_pathlib::violations::OsChmod,
rules::flake8_use_pathlib::violations::PathlibMkdir, rules::flake8_use_pathlib::violations::OsMkdir,
rules::flake8_use_pathlib::violations::PathlibMakedirs, rules::flake8_use_pathlib::violations::OsMakedirs,
rules::flake8_use_pathlib::violations::PathlibRename, rules::flake8_use_pathlib::violations::OsRename,
rules::flake8_use_pathlib::violations::PathlibReplace, rules::flake8_use_pathlib::violations::PathlibReplace,
rules::flake8_use_pathlib::violations::PathlibRmdir, rules::flake8_use_pathlib::violations::OsRmdir,
rules::flake8_use_pathlib::violations::PathlibRemove, rules::flake8_use_pathlib::violations::OsRemove,
rules::flake8_use_pathlib::violations::PathlibUnlink, rules::flake8_use_pathlib::violations::OsUnlink,
rules::flake8_use_pathlib::violations::PathlibGetcwd, rules::flake8_use_pathlib::violations::OsGetcwd,
rules::flake8_use_pathlib::violations::PathlibExists, rules::flake8_use_pathlib::violations::OsPathExists,
rules::flake8_use_pathlib::violations::PathlibExpanduser, rules::flake8_use_pathlib::violations::OsPathExpanduser,
rules::flake8_use_pathlib::violations::PathlibIsDir, rules::flake8_use_pathlib::violations::OsPathIsdir,
rules::flake8_use_pathlib::violations::PathlibIsFile, rules::flake8_use_pathlib::violations::OsPathIsfile,
rules::flake8_use_pathlib::violations::PathlibIsLink, rules::flake8_use_pathlib::violations::OsPathIslink,
rules::flake8_use_pathlib::violations::PathlibReadlink, rules::flake8_use_pathlib::violations::OsReadlink,
rules::flake8_use_pathlib::violations::PathlibStat, rules::flake8_use_pathlib::violations::OsStat,
rules::flake8_use_pathlib::violations::PathlibIsAbs, rules::flake8_use_pathlib::violations::OsPathIsabs,
rules::flake8_use_pathlib::violations::PathlibJoin, rules::flake8_use_pathlib::violations::OsPathJoin,
rules::flake8_use_pathlib::violations::PathlibBasename, rules::flake8_use_pathlib::violations::OsPathBasename,
rules::flake8_use_pathlib::violations::PathlibDirname, rules::flake8_use_pathlib::violations::OsPathDirname,
rules::flake8_use_pathlib::violations::PathlibSamefile, rules::flake8_use_pathlib::violations::OsPathSamefile,
rules::flake8_use_pathlib::violations::PathlibSplitext, rules::flake8_use_pathlib::violations::OsPathSplitext,
rules::flake8_use_pathlib::violations::PathlibOpen, rules::flake8_use_pathlib::violations::BuiltinOpen,
rules::flake8_use_pathlib::violations::PathlibPyPath, rules::flake8_use_pathlib::violations::PyPath,
// flake8-logging-format // flake8-logging-format
rules::flake8_logging_format::violations::LoggingStringFormat, rules::flake8_logging_format::violations::LoggingStringFormat,
rules::flake8_logging_format::violations::LoggingPercentFormat, rules::flake8_logging_format::violations::LoggingPercentFormat,

View File

@ -6,11 +6,10 @@ use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::registry::AsRule; use crate::registry::AsRule;
use crate::rules::flake8_use_pathlib::violations::{ use crate::rules::flake8_use_pathlib::violations::{
PathlibAbspath, PathlibBasename, PathlibChmod, PathlibDirname, PathlibExists, BuiltinOpen, OsChmod, OsGetcwd, OsMakedirs, OsMkdir, OsPathAbspath, OsPathBasename,
PathlibExpanduser, PathlibGetcwd, PathlibIsAbs, PathlibIsDir, PathlibIsFile, PathlibIsLink, OsPathDirname, OsPathExists, OsPathExpanduser, OsPathIsabs, OsPathIsdir, OsPathIsfile,
PathlibJoin, PathlibMakedirs, PathlibMkdir, PathlibOpen, PathlibPyPath, PathlibReadlink, OsPathIslink, OsPathJoin, OsPathSamefile, OsPathSplitext, OsReadlink, OsRemove, OsRename,
PathlibRemove, PathlibRename, PathlibReplace, PathlibRmdir, PathlibSamefile, PathlibSplitext, OsRmdir, OsStat, OsUnlink, PathlibReplace, PyPath,
PathlibStat, PathlibUnlink,
}; };
use crate::settings::types::PythonVersion; use crate::settings::types::PythonVersion;
@ -20,34 +19,34 @@ pub fn replaceable_by_pathlib(checker: &mut Checker, expr: &Expr) {
.ctx .ctx
.resolve_call_path(expr) .resolve_call_path(expr)
.and_then(|call_path| match call_path.as_slice() { .and_then(|call_path| match call_path.as_slice() {
["os", "path", "abspath"] => Some(PathlibAbspath.into()), ["os", "path", "abspath"] => Some(OsPathAbspath.into()),
["os", "chmod"] => Some(PathlibChmod.into()), ["os", "chmod"] => Some(OsChmod.into()),
["os", "mkdir"] => Some(PathlibMkdir.into()), ["os", "mkdir"] => Some(OsMkdir.into()),
["os", "makedirs"] => Some(PathlibMakedirs.into()), ["os", "makedirs"] => Some(OsMakedirs.into()),
["os", "rename"] => Some(PathlibRename.into()), ["os", "rename"] => Some(OsRename.into()),
["os", "replace"] => Some(PathlibReplace.into()), ["os", "replace"] => Some(PathlibReplace.into()),
["os", "rmdir"] => Some(PathlibRmdir.into()), ["os", "rmdir"] => Some(OsRmdir.into()),
["os", "remove"] => Some(PathlibRemove.into()), ["os", "remove"] => Some(OsRemove.into()),
["os", "unlink"] => Some(PathlibUnlink.into()), ["os", "unlink"] => Some(OsUnlink.into()),
["os", "getcwd"] => Some(PathlibGetcwd.into()), ["os", "getcwd"] => Some(OsGetcwd.into()),
["os", "getcwdb"] => Some(PathlibGetcwd.into()), ["os", "getcwdb"] => Some(OsGetcwd.into()),
["os", "path", "exists"] => Some(PathlibExists.into()), ["os", "path", "exists"] => Some(OsPathExists.into()),
["os", "path", "expanduser"] => Some(PathlibExpanduser.into()), ["os", "path", "expanduser"] => Some(OsPathExpanduser.into()),
["os", "path", "isdir"] => Some(PathlibIsDir.into()), ["os", "path", "isdir"] => Some(OsPathIsdir.into()),
["os", "path", "isfile"] => Some(PathlibIsFile.into()), ["os", "path", "isfile"] => Some(OsPathIsfile.into()),
["os", "path", "islink"] => Some(PathlibIsLink.into()), ["os", "path", "islink"] => Some(OsPathIslink.into()),
["os", "stat"] => Some(PathlibStat.into()), ["os", "stat"] => Some(OsStat.into()),
["os", "path", "isabs"] => Some(PathlibIsAbs.into()), ["os", "path", "isabs"] => Some(OsPathIsabs.into()),
["os", "path", "join"] => Some(PathlibJoin.into()), ["os", "path", "join"] => Some(OsPathJoin.into()),
["os", "path", "basename"] => Some(PathlibBasename.into()), ["os", "path", "basename"] => Some(OsPathBasename.into()),
["os", "path", "dirname"] => Some(PathlibDirname.into()), ["os", "path", "dirname"] => Some(OsPathDirname.into()),
["os", "path", "samefile"] => Some(PathlibSamefile.into()), ["os", "path", "samefile"] => Some(OsPathSamefile.into()),
["os", "path", "splitext"] => Some(PathlibSplitext.into()), ["os", "path", "splitext"] => Some(OsPathSplitext.into()),
["", "open"] => Some(PathlibOpen.into()), ["", "open"] => Some(BuiltinOpen.into()),
["py", "path", "local"] => Some(PathlibPyPath.into()), ["py", "path", "local"] => Some(PyPath.into()),
// Python 3.9+ // Python 3.9+
["os", "readlink"] if checker.settings.target_version >= PythonVersion::Py39 => { ["os", "readlink"] if checker.settings.target_version >= PythonVersion::Py39 => {
Some(PathlibReadlink.into()) Some(OsReadlink.into())
} }
_ => None, _ => None,
}) })

View File

@ -23,38 +23,38 @@ mod tests {
let diagnostics = test_path( let diagnostics = test_path(
Path::new("flake8_use_pathlib").join(path).as_path(), Path::new("flake8_use_pathlib").join(path).as_path(),
&settings::Settings::for_rules(vec![ &settings::Settings::for_rules(vec![
Rule::PathlibAbspath, Rule::OsPathAbspath,
Rule::PathlibChmod, Rule::OsChmod,
Rule::PathlibMkdir, Rule::OsMkdir,
Rule::PathlibMakedirs, Rule::OsMakedirs,
Rule::PathlibRename, Rule::OsRename,
Rule::PathlibReplace, Rule::PathlibReplace,
Rule::PathlibRmdir, Rule::OsRmdir,
Rule::PathlibRemove, Rule::OsRemove,
Rule::PathlibUnlink, Rule::OsUnlink,
Rule::PathlibGetcwd, Rule::OsGetcwd,
Rule::PathlibExists, Rule::OsPathExists,
Rule::PathlibExpanduser, Rule::OsPathExpanduser,
Rule::PathlibIsDir, Rule::OsPathIsdir,
Rule::PathlibIsFile, Rule::OsPathIsfile,
Rule::PathlibIsLink, Rule::OsPathIslink,
Rule::PathlibReadlink, Rule::OsReadlink,
Rule::PathlibStat, Rule::OsStat,
Rule::PathlibIsAbs, Rule::OsPathIsabs,
Rule::PathlibJoin, Rule::OsPathJoin,
Rule::PathlibBasename, Rule::OsPathBasename,
Rule::PathlibDirname, Rule::OsPathDirname,
Rule::PathlibSamefile, Rule::OsPathSamefile,
Rule::PathlibSplitext, Rule::OsPathSplitext,
Rule::PathlibOpen, Rule::BuiltinOpen,
]), ]),
)?; )?;
insta::assert_yaml_snapshot!(snapshot, diagnostics); insta::assert_yaml_snapshot!(snapshot, diagnostics);
Ok(()) Ok(())
} }
#[test_case(Rule::PathlibPyPath, Path::new("py_path_1.py"); "PTH024_1")] #[test_case(Rule::PyPath, Path::new("py_path_1.py"); "PTH024_1")]
#[test_case(Rule::PathlibPyPath, Path::new("py_path_2.py"); "PTH024_2")] #[test_case(Rule::PyPath, Path::new("py_path_2.py"); "PTH024_2")]
fn rules_pypath(rule_code: Rule, path: &Path) -> Result<()> { fn rules_pypath(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path( let diagnostics = test_path(

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibPyPath name: PyPath
body: "`py.path` is in maintenance mode, use `pathlib` instead" body: "`py.path` is in maintenance mode, use `pathlib` instead"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibPyPath name: PyPath
body: "`py.path` is in maintenance mode, use `pathlib` instead" body: "`py.path` is in maintenance mode, use `pathlib` instead"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibAbspath name: OsPathAbspath
body: "`os.path.abspath()` should be replaced by `Path.resolve()`" body: "`os.path.abspath()` should be replaced by `Path.resolve()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -16,7 +16,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibChmod name: OsChmod
body: "`os.chmod()` should be replaced by `Path.chmod()`" body: "`os.chmod()` should be replaced by `Path.chmod()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -29,7 +29,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMkdir name: OsMkdir
body: "`os.mkdir()` should be replaced by `Path.mkdir()`" body: "`os.mkdir()` should be replaced by `Path.mkdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -42,7 +42,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMakedirs name: OsMakedirs
body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -55,7 +55,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRename name: OsRename
body: "`os.rename()` should be replaced by `Path.rename()`" body: "`os.rename()` should be replaced by `Path.rename()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -81,7 +81,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRmdir name: OsRmdir
body: "`os.rmdir()` should be replaced by `Path.rmdir()`" body: "`os.rmdir()` should be replaced by `Path.rmdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -94,7 +94,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRemove name: OsRemove
body: "`os.remove()` should be replaced by `Path.unlink()`" body: "`os.remove()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -107,7 +107,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibUnlink name: OsUnlink
body: "`os.unlink()` should be replaced by `Path.unlink()`" body: "`os.unlink()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -120,7 +120,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibGetcwd name: OsGetcwd
body: "`os.getcwd()` should be replaced by `Path.cwd()`" body: "`os.getcwd()` should be replaced by `Path.cwd()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -133,7 +133,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExists name: OsPathExists
body: "`os.path.exists()` should be replaced by `Path.exists()`" body: "`os.path.exists()` should be replaced by `Path.exists()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -146,7 +146,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExpanduser name: OsPathExpanduser
body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -159,7 +159,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsDir name: OsPathIsdir
body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" body: "`os.path.isdir()` should be replaced by `Path.is_dir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -172,7 +172,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsFile name: OsPathIsfile
body: "`os.path.isfile()` should be replaced by `Path.is_file()`" body: "`os.path.isfile()` should be replaced by `Path.is_file()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -185,7 +185,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsLink name: OsPathIslink
body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" body: "`os.path.islink()` should be replaced by `Path.is_symlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -198,7 +198,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibReadlink name: OsReadlink
body: "`os.readlink()` should be replaced by `Path.readlink()`" body: "`os.readlink()` should be replaced by `Path.readlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -211,7 +211,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibStat name: OsStat
body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -224,7 +224,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsAbs name: OsPathIsabs
body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -237,7 +237,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibJoin name: OsPathJoin
body: "`os.path.join()` should be replaced by `Path` with `/` operator" body: "`os.path.join()` should be replaced by `Path` with `/` operator"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -250,7 +250,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibBasename name: OsPathBasename
body: "`os.path.basename()` should be replaced by `Path.name`" body: "`os.path.basename()` should be replaced by `Path.name`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -263,7 +263,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibDirname name: OsPathDirname
body: "`os.path.dirname()` should be replaced by `Path.parent`" body: "`os.path.dirname()` should be replaced by `Path.parent`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -276,7 +276,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSamefile name: OsPathSamefile
body: "`os.path.samefile()` should be replaced by `Path.samefile()`" body: "`os.path.samefile()` should be replaced by `Path.samefile()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -289,7 +289,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSplitext name: OsPathSplitext
body: "`os.path.splitext()` should be replaced by `Path.suffix`" body: "`os.path.splitext()` should be replaced by `Path.suffix`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -302,7 +302,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibOpen name: BuiltinOpen
body: "`open()` should be replaced by `Path.open()`" body: "`open()` should be replaced by `Path.open()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -315,7 +315,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibOpen name: BuiltinOpen
body: "`open()` should be replaced by `Path.open()`" body: "`open()` should be replaced by `Path.open()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -328,7 +328,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibGetcwd name: OsGetcwd
body: "`os.getcwd()` should be replaced by `Path.cwd()`" body: "`os.getcwd()` should be replaced by `Path.cwd()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibAbspath name: OsPathAbspath
body: "`os.path.abspath()` should be replaced by `Path.resolve()`" body: "`os.path.abspath()` should be replaced by `Path.resolve()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -16,7 +16,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibChmod name: OsChmod
body: "`os.chmod()` should be replaced by `Path.chmod()`" body: "`os.chmod()` should be replaced by `Path.chmod()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -29,7 +29,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMkdir name: OsMkdir
body: "`os.mkdir()` should be replaced by `Path.mkdir()`" body: "`os.mkdir()` should be replaced by `Path.mkdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -42,7 +42,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMakedirs name: OsMakedirs
body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -55,7 +55,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRename name: OsRename
body: "`os.rename()` should be replaced by `Path.rename()`" body: "`os.rename()` should be replaced by `Path.rename()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -81,7 +81,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRmdir name: OsRmdir
body: "`os.rmdir()` should be replaced by `Path.rmdir()`" body: "`os.rmdir()` should be replaced by `Path.rmdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -94,7 +94,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRemove name: OsRemove
body: "`os.remove()` should be replaced by `Path.unlink()`" body: "`os.remove()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -107,7 +107,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibUnlink name: OsUnlink
body: "`os.unlink()` should be replaced by `Path.unlink()`" body: "`os.unlink()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -120,7 +120,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibGetcwd name: OsGetcwd
body: "`os.getcwd()` should be replaced by `Path.cwd()`" body: "`os.getcwd()` should be replaced by `Path.cwd()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -133,7 +133,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExists name: OsPathExists
body: "`os.path.exists()` should be replaced by `Path.exists()`" body: "`os.path.exists()` should be replaced by `Path.exists()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -146,7 +146,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExpanduser name: OsPathExpanduser
body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -159,7 +159,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsDir name: OsPathIsdir
body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" body: "`os.path.isdir()` should be replaced by `Path.is_dir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -172,7 +172,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsFile name: OsPathIsfile
body: "`os.path.isfile()` should be replaced by `Path.is_file()`" body: "`os.path.isfile()` should be replaced by `Path.is_file()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -185,7 +185,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsLink name: OsPathIslink
body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" body: "`os.path.islink()` should be replaced by `Path.is_symlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -198,7 +198,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibReadlink name: OsReadlink
body: "`os.readlink()` should be replaced by `Path.readlink()`" body: "`os.readlink()` should be replaced by `Path.readlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -211,7 +211,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibStat name: OsStat
body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -224,7 +224,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsAbs name: OsPathIsabs
body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -237,7 +237,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibJoin name: OsPathJoin
body: "`os.path.join()` should be replaced by `Path` with `/` operator" body: "`os.path.join()` should be replaced by `Path` with `/` operator"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -250,7 +250,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibBasename name: OsPathBasename
body: "`os.path.basename()` should be replaced by `Path.name`" body: "`os.path.basename()` should be replaced by `Path.name`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -263,7 +263,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibDirname name: OsPathDirname
body: "`os.path.dirname()` should be replaced by `Path.parent`" body: "`os.path.dirname()` should be replaced by `Path.parent`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -276,7 +276,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSamefile name: OsPathSamefile
body: "`os.path.samefile()` should be replaced by `Path.samefile()`" body: "`os.path.samefile()` should be replaced by `Path.samefile()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -289,7 +289,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSplitext name: OsPathSplitext
body: "`os.path.splitext()` should be replaced by `Path.suffix`" body: "`os.path.splitext()` should be replaced by `Path.suffix`"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibAbspath name: OsPathAbspath
body: "`os.path.abspath()` should be replaced by `Path.resolve()`" body: "`os.path.abspath()` should be replaced by `Path.resolve()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -16,7 +16,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibChmod name: OsChmod
body: "`os.chmod()` should be replaced by `Path.chmod()`" body: "`os.chmod()` should be replaced by `Path.chmod()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -29,7 +29,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMkdir name: OsMkdir
body: "`os.mkdir()` should be replaced by `Path.mkdir()`" body: "`os.mkdir()` should be replaced by `Path.mkdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -42,7 +42,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMakedirs name: OsMakedirs
body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -55,7 +55,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRename name: OsRename
body: "`os.rename()` should be replaced by `Path.rename()`" body: "`os.rename()` should be replaced by `Path.rename()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -81,7 +81,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRmdir name: OsRmdir
body: "`os.rmdir()` should be replaced by `Path.rmdir()`" body: "`os.rmdir()` should be replaced by `Path.rmdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -94,7 +94,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRemove name: OsRemove
body: "`os.remove()` should be replaced by `Path.unlink()`" body: "`os.remove()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -107,7 +107,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibUnlink name: OsUnlink
body: "`os.unlink()` should be replaced by `Path.unlink()`" body: "`os.unlink()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -120,7 +120,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibGetcwd name: OsGetcwd
body: "`os.getcwd()` should be replaced by `Path.cwd()`" body: "`os.getcwd()` should be replaced by `Path.cwd()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -133,7 +133,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExists name: OsPathExists
body: "`os.path.exists()` should be replaced by `Path.exists()`" body: "`os.path.exists()` should be replaced by `Path.exists()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -146,7 +146,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExpanduser name: OsPathExpanduser
body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -159,7 +159,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsDir name: OsPathIsdir
body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" body: "`os.path.isdir()` should be replaced by `Path.is_dir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -172,7 +172,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsFile name: OsPathIsfile
body: "`os.path.isfile()` should be replaced by `Path.is_file()`" body: "`os.path.isfile()` should be replaced by `Path.is_file()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -185,7 +185,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsLink name: OsPathIslink
body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" body: "`os.path.islink()` should be replaced by `Path.is_symlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -198,7 +198,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibReadlink name: OsReadlink
body: "`os.readlink()` should be replaced by `Path.readlink()`" body: "`os.readlink()` should be replaced by `Path.readlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -211,7 +211,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibStat name: OsStat
body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -224,7 +224,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsAbs name: OsPathIsabs
body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -237,7 +237,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibJoin name: OsPathJoin
body: "`os.path.join()` should be replaced by `Path` with `/` operator" body: "`os.path.join()` should be replaced by `Path` with `/` operator"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -250,7 +250,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibBasename name: OsPathBasename
body: "`os.path.basename()` should be replaced by `Path.name`" body: "`os.path.basename()` should be replaced by `Path.name`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -263,7 +263,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibDirname name: OsPathDirname
body: "`os.path.dirname()` should be replaced by `Path.parent`" body: "`os.path.dirname()` should be replaced by `Path.parent`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -276,7 +276,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSamefile name: OsPathSamefile
body: "`os.path.samefile()` should be replaced by `Path.samefile()`" body: "`os.path.samefile()` should be replaced by `Path.samefile()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -289,7 +289,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSplitext name: OsPathSplitext
body: "`os.path.splitext()` should be replaced by `Path.suffix`" body: "`os.path.splitext()` should be replaced by `Path.suffix`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -302,7 +302,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibOpen name: BuiltinOpen
body: "`open()` should be replaced by `Path.open()`" body: "`open()` should be replaced by `Path.open()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -315,7 +315,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibOpen name: BuiltinOpen
body: "`open()` should be replaced by `Path.open()`" body: "`open()` should be replaced by `Path.open()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
expression: diagnostics expression: diagnostics
--- ---
- kind: - kind:
name: PathlibAbspath name: OsPathAbspath
body: "`os.path.abspath()` should be replaced by `Path.resolve()`" body: "`os.path.abspath()` should be replaced by `Path.resolve()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -16,7 +16,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibChmod name: OsChmod
body: "`os.chmod()` should be replaced by `Path.chmod()`" body: "`os.chmod()` should be replaced by `Path.chmod()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -29,7 +29,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMkdir name: OsMkdir
body: "`os.mkdir()` should be replaced by `Path.mkdir()`" body: "`os.mkdir()` should be replaced by `Path.mkdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -42,7 +42,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibMakedirs name: OsMakedirs
body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -55,7 +55,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRename name: OsRename
body: "`os.rename()` should be replaced by `Path.rename()`" body: "`os.rename()` should be replaced by `Path.rename()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -81,7 +81,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRmdir name: OsRmdir
body: "`os.rmdir()` should be replaced by `Path.rmdir()`" body: "`os.rmdir()` should be replaced by `Path.rmdir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -94,7 +94,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibRemove name: OsRemove
body: "`os.remove()` should be replaced by `Path.unlink()`" body: "`os.remove()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -107,7 +107,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibUnlink name: OsUnlink
body: "`os.unlink()` should be replaced by `Path.unlink()`" body: "`os.unlink()` should be replaced by `Path.unlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -120,7 +120,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibGetcwd name: OsGetcwd
body: "`os.getcwd()` should be replaced by `Path.cwd()`" body: "`os.getcwd()` should be replaced by `Path.cwd()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -133,7 +133,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExists name: OsPathExists
body: "`os.path.exists()` should be replaced by `Path.exists()`" body: "`os.path.exists()` should be replaced by `Path.exists()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -146,7 +146,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibExpanduser name: OsPathExpanduser
body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -159,7 +159,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsDir name: OsPathIsdir
body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" body: "`os.path.isdir()` should be replaced by `Path.is_dir()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -172,7 +172,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsFile name: OsPathIsfile
body: "`os.path.isfile()` should be replaced by `Path.is_file()`" body: "`os.path.isfile()` should be replaced by `Path.is_file()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -185,7 +185,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsLink name: OsPathIslink
body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" body: "`os.path.islink()` should be replaced by `Path.is_symlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -198,7 +198,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibReadlink name: OsReadlink
body: "`os.readlink()` should be replaced by `Path.readlink()`" body: "`os.readlink()` should be replaced by `Path.readlink()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -211,7 +211,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibStat name: OsStat
body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -224,7 +224,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibIsAbs name: OsPathIsabs
body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -237,7 +237,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibJoin name: OsPathJoin
body: "`os.path.join()` should be replaced by `Path` with `/` operator" body: "`os.path.join()` should be replaced by `Path` with `/` operator"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -250,7 +250,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibBasename name: OsPathBasename
body: "`os.path.basename()` should be replaced by `Path.name`" body: "`os.path.basename()` should be replaced by `Path.name`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -263,7 +263,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibDirname name: OsPathDirname
body: "`os.path.dirname()` should be replaced by `Path.parent`" body: "`os.path.dirname()` should be replaced by `Path.parent`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -276,7 +276,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSamefile name: OsPathSamefile
body: "`os.path.samefile()` should be replaced by `Path.samefile()`" body: "`os.path.samefile()` should be replaced by `Path.samefile()`"
suggestion: ~ suggestion: ~
fixable: false fixable: false
@ -289,7 +289,7 @@ expression: diagnostics
fix: ~ fix: ~
parent: ~ parent: ~
- kind: - kind:
name: PathlibSplitext name: OsPathSplitext
body: "`os.path.splitext()` should be replaced by `Path.suffix`" body: "`os.path.splitext()` should be replaced by `Path.suffix`"
suggestion: ~ suggestion: ~
fixable: false fixable: false

View File

@ -3,9 +3,9 @@ use ruff_macros::{derive_message_formats, violation};
// PTH100 // PTH100
#[violation] #[violation]
pub struct PathlibAbspath; pub struct OsPathAbspath;
impl Violation for PathlibAbspath { impl Violation for OsPathAbspath {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.abspath()` should be replaced by `Path.resolve()`") format!("`os.path.abspath()` should be replaced by `Path.resolve()`")
@ -14,9 +14,9 @@ impl Violation for PathlibAbspath {
// PTH101 // PTH101
#[violation] #[violation]
pub struct PathlibChmod; pub struct OsChmod;
impl Violation for PathlibChmod { impl Violation for OsChmod {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.chmod()` should be replaced by `Path.chmod()`") format!("`os.chmod()` should be replaced by `Path.chmod()`")
@ -25,9 +25,9 @@ impl Violation for PathlibChmod {
// PTH102 // PTH102
#[violation] #[violation]
pub struct PathlibMakedirs; pub struct OsMakedirs;
impl Violation for PathlibMakedirs { impl Violation for OsMakedirs {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`") format!("`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`")
@ -36,9 +36,9 @@ impl Violation for PathlibMakedirs {
// PTH103 // PTH103
#[violation] #[violation]
pub struct PathlibMkdir; pub struct OsMkdir;
impl Violation for PathlibMkdir { impl Violation for OsMkdir {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.mkdir()` should be replaced by `Path.mkdir()`") format!("`os.mkdir()` should be replaced by `Path.mkdir()`")
@ -47,9 +47,9 @@ impl Violation for PathlibMkdir {
// PTH104 // PTH104
#[violation] #[violation]
pub struct PathlibRename; pub struct OsRename;
impl Violation for PathlibRename { impl Violation for OsRename {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.rename()` should be replaced by `Path.rename()`") format!("`os.rename()` should be replaced by `Path.rename()`")
@ -69,9 +69,9 @@ impl Violation for PathlibReplace {
// PTH106 // PTH106
#[violation] #[violation]
pub struct PathlibRmdir; pub struct OsRmdir;
impl Violation for PathlibRmdir { impl Violation for OsRmdir {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.rmdir()` should be replaced by `Path.rmdir()`") format!("`os.rmdir()` should be replaced by `Path.rmdir()`")
@ -80,9 +80,9 @@ impl Violation for PathlibRmdir {
// PTH107 // PTH107
#[violation] #[violation]
pub struct PathlibRemove; pub struct OsRemove;
impl Violation for PathlibRemove { impl Violation for OsRemove {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.remove()` should be replaced by `Path.unlink()`") format!("`os.remove()` should be replaced by `Path.unlink()`")
@ -91,9 +91,9 @@ impl Violation for PathlibRemove {
// PTH108 // PTH108
#[violation] #[violation]
pub struct PathlibUnlink; pub struct OsUnlink;
impl Violation for PathlibUnlink { impl Violation for OsUnlink {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.unlink()` should be replaced by `Path.unlink()`") format!("`os.unlink()` should be replaced by `Path.unlink()`")
@ -102,9 +102,9 @@ impl Violation for PathlibUnlink {
// PTH109 // PTH109
#[violation] #[violation]
pub struct PathlibGetcwd; pub struct OsGetcwd;
impl Violation for PathlibGetcwd { impl Violation for OsGetcwd {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.getcwd()` should be replaced by `Path.cwd()`") format!("`os.getcwd()` should be replaced by `Path.cwd()`")
@ -113,9 +113,9 @@ impl Violation for PathlibGetcwd {
// PTH110 // PTH110
#[violation] #[violation]
pub struct PathlibExists; pub struct OsPathExists;
impl Violation for PathlibExists { impl Violation for OsPathExists {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.exists()` should be replaced by `Path.exists()`") format!("`os.path.exists()` should be replaced by `Path.exists()`")
@ -124,9 +124,9 @@ impl Violation for PathlibExists {
// PTH111 // PTH111
#[violation] #[violation]
pub struct PathlibExpanduser; pub struct OsPathExpanduser;
impl Violation for PathlibExpanduser { impl Violation for OsPathExpanduser {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.expanduser()` should be replaced by `Path.expanduser()`") format!("`os.path.expanduser()` should be replaced by `Path.expanduser()`")
@ -135,9 +135,9 @@ impl Violation for PathlibExpanduser {
// PTH112 // PTH112
#[violation] #[violation]
pub struct PathlibIsDir; pub struct OsPathIsdir;
impl Violation for PathlibIsDir { impl Violation for OsPathIsdir {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.isdir()` should be replaced by `Path.is_dir()`") format!("`os.path.isdir()` should be replaced by `Path.is_dir()`")
@ -146,9 +146,9 @@ impl Violation for PathlibIsDir {
// PTH113 // PTH113
#[violation] #[violation]
pub struct PathlibIsFile; pub struct OsPathIsfile;
impl Violation for PathlibIsFile { impl Violation for OsPathIsfile {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.isfile()` should be replaced by `Path.is_file()`") format!("`os.path.isfile()` should be replaced by `Path.is_file()`")
@ -157,9 +157,9 @@ impl Violation for PathlibIsFile {
// PTH114 // PTH114
#[violation] #[violation]
pub struct PathlibIsLink; pub struct OsPathIslink;
impl Violation for PathlibIsLink { impl Violation for OsPathIslink {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.islink()` should be replaced by `Path.is_symlink()`") format!("`os.path.islink()` should be replaced by `Path.is_symlink()`")
@ -168,9 +168,9 @@ impl Violation for PathlibIsLink {
// PTH115 // PTH115
#[violation] #[violation]
pub struct PathlibReadlink; pub struct OsReadlink;
impl Violation for PathlibReadlink { impl Violation for OsReadlink {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.readlink()` should be replaced by `Path.readlink()`") format!("`os.readlink()` should be replaced by `Path.readlink()`")
@ -179,9 +179,9 @@ impl Violation for PathlibReadlink {
// PTH116 // PTH116
#[violation] #[violation]
pub struct PathlibStat; pub struct OsStat;
impl Violation for PathlibStat { impl Violation for OsStat {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!( format!(
@ -192,9 +192,9 @@ impl Violation for PathlibStat {
// PTH117 // PTH117
#[violation] #[violation]
pub struct PathlibIsAbs; pub struct OsPathIsabs;
impl Violation for PathlibIsAbs { impl Violation for OsPathIsabs {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.isabs()` should be replaced by `Path.is_absolute()`") format!("`os.path.isabs()` should be replaced by `Path.is_absolute()`")
@ -203,9 +203,9 @@ impl Violation for PathlibIsAbs {
// PTH118 // PTH118
#[violation] #[violation]
pub struct PathlibJoin; pub struct OsPathJoin;
impl Violation for PathlibJoin { impl Violation for OsPathJoin {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.join()` should be replaced by `Path` with `/` operator") format!("`os.path.join()` should be replaced by `Path` with `/` operator")
@ -214,9 +214,9 @@ impl Violation for PathlibJoin {
// PTH119 // PTH119
#[violation] #[violation]
pub struct PathlibBasename; pub struct OsPathBasename;
impl Violation for PathlibBasename { impl Violation for OsPathBasename {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.basename()` should be replaced by `Path.name`") format!("`os.path.basename()` should be replaced by `Path.name`")
@ -225,9 +225,9 @@ impl Violation for PathlibBasename {
// PTH120 // PTH120
#[violation] #[violation]
pub struct PathlibDirname; pub struct OsPathDirname;
impl Violation for PathlibDirname { impl Violation for OsPathDirname {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.dirname()` should be replaced by `Path.parent`") format!("`os.path.dirname()` should be replaced by `Path.parent`")
@ -236,9 +236,9 @@ impl Violation for PathlibDirname {
// PTH121 // PTH121
#[violation] #[violation]
pub struct PathlibSamefile; pub struct OsPathSamefile;
impl Violation for PathlibSamefile { impl Violation for OsPathSamefile {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.samefile()` should be replaced by `Path.samefile()`") format!("`os.path.samefile()` should be replaced by `Path.samefile()`")
@ -247,9 +247,9 @@ impl Violation for PathlibSamefile {
// PTH122 // PTH122
#[violation] #[violation]
pub struct PathlibSplitext; pub struct OsPathSplitext;
impl Violation for PathlibSplitext { impl Violation for OsPathSplitext {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`os.path.splitext()` should be replaced by `Path.suffix`") format!("`os.path.splitext()` should be replaced by `Path.suffix`")
@ -258,9 +258,9 @@ impl Violation for PathlibSplitext {
// PTH123 // PTH123
#[violation] #[violation]
pub struct PathlibOpen; pub struct BuiltinOpen;
impl Violation for PathlibOpen { impl Violation for BuiltinOpen {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`open()` should be replaced by `Path.open()`") format!("`open()` should be replaced by `Path.open()`")
@ -269,9 +269,9 @@ impl Violation for PathlibOpen {
// PTH124 // PTH124
#[violation] #[violation]
pub struct PathlibPyPath; pub struct PyPath;
impl Violation for PathlibPyPath { impl Violation for PyPath {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
format!("`py.path` is in maintenance mode, use `pathlib` instead") format!("`py.path` is in maintenance mode, use `pathlib` instead")