From 875f61cb622f7c25b9ae6029ad2c2fd9dbd95131 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 22 Mar 2023 11:35:45 -0400 Subject: [PATCH] Rename `pathlib` rules to match updated naming convention (#3660) --- crates/ruff/src/checkers/ast/mod.rs | 46 ++++----- crates/ruff/src/codes.rs | 48 +++++----- crates/ruff/src/registry.rs | 48 +++++----- .../src/rules/flake8_use_pathlib/helpers.rs | 59 ++++++------ .../ruff/src/rules/flake8_use_pathlib/mod.rs | 50 +++++----- ...e_pathlib__tests__PTH124_py_path_1.py.snap | 2 +- ...e_pathlib__tests__PTH124_py_path_2.py.snap | 2 +- ...ake8_use_pathlib__tests__full_name.py.snap | 50 +++++----- ...ake8_use_pathlib__tests__import_as.py.snap | 44 ++++----- ...e8_use_pathlib__tests__import_from.py.snap | 48 +++++----- ...use_pathlib__tests__import_from_as.py.snap | 44 ++++----- .../rules/flake8_use_pathlib/violations.rs | 96 +++++++++---------- 12 files changed, 268 insertions(+), 269 deletions(-) diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index 886e47e55e..ae33ecd8c1 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -2886,30 +2886,30 @@ where // flake8-use-pathlib if self.settings.rules.any_enabled(&[ - Rule::PathlibAbspath, - Rule::PathlibChmod, - Rule::PathlibMkdir, - Rule::PathlibMakedirs, - Rule::PathlibRename, + Rule::OsPathAbspath, + Rule::OsChmod, + Rule::OsMkdir, + Rule::OsMakedirs, + Rule::OsRename, Rule::PathlibReplace, - Rule::PathlibRmdir, - Rule::PathlibRemove, - Rule::PathlibUnlink, - Rule::PathlibGetcwd, - Rule::PathlibExists, - Rule::PathlibExpanduser, - Rule::PathlibIsDir, - Rule::PathlibIsFile, - Rule::PathlibIsLink, - Rule::PathlibReadlink, - Rule::PathlibStat, - Rule::PathlibIsAbs, - Rule::PathlibJoin, - Rule::PathlibBasename, - Rule::PathlibSamefile, - Rule::PathlibSplitext, - Rule::PathlibOpen, - Rule::PathlibPyPath, + Rule::OsRmdir, + Rule::OsRemove, + Rule::OsUnlink, + Rule::OsGetcwd, + Rule::OsPathExists, + Rule::OsPathExpanduser, + Rule::OsPathIsdir, + Rule::OsPathIsfile, + Rule::OsPathIslink, + Rule::OsReadlink, + Rule::OsStat, + Rule::OsPathIsabs, + Rule::OsPathJoin, + Rule::OsPathBasename, + Rule::OsPathSamefile, + Rule::OsPathSplitext, + Rule::BuiltinOpen, + Rule::PyPath, ]) { flake8_use_pathlib::helpers::replaceable_by_pathlib(self, func); } diff --git a/crates/ruff/src/codes.rs b/crates/ruff/src/codes.rs index f57c41a313..6e33011c65 100644 --- a/crates/ruff/src/codes.rs +++ b/crates/ruff/src/codes.rs @@ -638,31 +638,31 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Tryceratops, "401") => Rule::VerboseLogMessage, // flake8-use-pathlib - (Flake8UsePathlib, "100") => Rule::PathlibAbspath, - (Flake8UsePathlib, "101") => Rule::PathlibChmod, - (Flake8UsePathlib, "102") => Rule::PathlibMkdir, - (Flake8UsePathlib, "103") => Rule::PathlibMakedirs, - (Flake8UsePathlib, "104") => Rule::PathlibRename, + (Flake8UsePathlib, "100") => Rule::OsPathAbspath, + (Flake8UsePathlib, "101") => Rule::OsChmod, + (Flake8UsePathlib, "102") => Rule::OsMkdir, + (Flake8UsePathlib, "103") => Rule::OsMakedirs, + (Flake8UsePathlib, "104") => Rule::OsRename, (Flake8UsePathlib, "105") => Rule::PathlibReplace, - (Flake8UsePathlib, "106") => Rule::PathlibRmdir, - (Flake8UsePathlib, "107") => Rule::PathlibRemove, - (Flake8UsePathlib, "108") => Rule::PathlibUnlink, - (Flake8UsePathlib, "109") => Rule::PathlibGetcwd, - (Flake8UsePathlib, "110") => Rule::PathlibExists, - (Flake8UsePathlib, "111") => Rule::PathlibExpanduser, - (Flake8UsePathlib, "112") => Rule::PathlibIsDir, - (Flake8UsePathlib, "113") => Rule::PathlibIsFile, - (Flake8UsePathlib, "114") => Rule::PathlibIsLink, - (Flake8UsePathlib, "115") => Rule::PathlibReadlink, - (Flake8UsePathlib, "116") => Rule::PathlibStat, - (Flake8UsePathlib, "117") => Rule::PathlibIsAbs, - (Flake8UsePathlib, "118") => Rule::PathlibJoin, - (Flake8UsePathlib, "119") => Rule::PathlibBasename, - (Flake8UsePathlib, "120") => Rule::PathlibDirname, - (Flake8UsePathlib, "121") => Rule::PathlibSamefile, - (Flake8UsePathlib, "122") => Rule::PathlibSplitext, - (Flake8UsePathlib, "123") => Rule::PathlibOpen, - (Flake8UsePathlib, "124") => Rule::PathlibPyPath, + (Flake8UsePathlib, "106") => Rule::OsRmdir, + (Flake8UsePathlib, "107") => Rule::OsRemove, + (Flake8UsePathlib, "108") => Rule::OsUnlink, + (Flake8UsePathlib, "109") => Rule::OsGetcwd, + (Flake8UsePathlib, "110") => Rule::OsPathExists, + (Flake8UsePathlib, "111") => Rule::OsPathExpanduser, + (Flake8UsePathlib, "112") => Rule::OsPathIsdir, + (Flake8UsePathlib, "113") => Rule::OsPathIsfile, + (Flake8UsePathlib, "114") => Rule::OsPathIslink, + (Flake8UsePathlib, "115") => Rule::OsReadlink, + (Flake8UsePathlib, "116") => Rule::OsStat, + (Flake8UsePathlib, "117") => Rule::OsPathIsabs, + (Flake8UsePathlib, "118") => Rule::OsPathJoin, + (Flake8UsePathlib, "119") => Rule::OsPathBasename, + (Flake8UsePathlib, "120") => Rule::OsPathDirname, + (Flake8UsePathlib, "121") => Rule::OsPathSamefile, + (Flake8UsePathlib, "122") => Rule::OsPathSplitext, + (Flake8UsePathlib, "123") => Rule::BuiltinOpen, + (Flake8UsePathlib, "124") => Rule::PyPath, // flake8-logging-format (Flake8LoggingFormat, "001") => Rule::LoggingStringFormat, diff --git a/crates/ruff/src/registry.rs b/crates/ruff/src/registry.rs index 96965af616..3beec4f22d 100644 --- a/crates/ruff/src/registry.rs +++ b/crates/ruff/src/registry.rs @@ -587,31 +587,31 @@ ruff_macros::register_rules!( rules::tryceratops::rules::ErrorInsteadOfException, rules::tryceratops::rules::VerboseLogMessage, // flake8-use-pathlib - rules::flake8_use_pathlib::violations::PathlibAbspath, - rules::flake8_use_pathlib::violations::PathlibChmod, - rules::flake8_use_pathlib::violations::PathlibMkdir, - rules::flake8_use_pathlib::violations::PathlibMakedirs, - rules::flake8_use_pathlib::violations::PathlibRename, + rules::flake8_use_pathlib::violations::OsPathAbspath, + rules::flake8_use_pathlib::violations::OsChmod, + rules::flake8_use_pathlib::violations::OsMkdir, + rules::flake8_use_pathlib::violations::OsMakedirs, + rules::flake8_use_pathlib::violations::OsRename, rules::flake8_use_pathlib::violations::PathlibReplace, - rules::flake8_use_pathlib::violations::PathlibRmdir, - rules::flake8_use_pathlib::violations::PathlibRemove, - rules::flake8_use_pathlib::violations::PathlibUnlink, - rules::flake8_use_pathlib::violations::PathlibGetcwd, - rules::flake8_use_pathlib::violations::PathlibExists, - rules::flake8_use_pathlib::violations::PathlibExpanduser, - rules::flake8_use_pathlib::violations::PathlibIsDir, - rules::flake8_use_pathlib::violations::PathlibIsFile, - rules::flake8_use_pathlib::violations::PathlibIsLink, - rules::flake8_use_pathlib::violations::PathlibReadlink, - rules::flake8_use_pathlib::violations::PathlibStat, - rules::flake8_use_pathlib::violations::PathlibIsAbs, - rules::flake8_use_pathlib::violations::PathlibJoin, - rules::flake8_use_pathlib::violations::PathlibBasename, - rules::flake8_use_pathlib::violations::PathlibDirname, - rules::flake8_use_pathlib::violations::PathlibSamefile, - rules::flake8_use_pathlib::violations::PathlibSplitext, - rules::flake8_use_pathlib::violations::PathlibOpen, - rules::flake8_use_pathlib::violations::PathlibPyPath, + rules::flake8_use_pathlib::violations::OsRmdir, + rules::flake8_use_pathlib::violations::OsRemove, + rules::flake8_use_pathlib::violations::OsUnlink, + rules::flake8_use_pathlib::violations::OsGetcwd, + rules::flake8_use_pathlib::violations::OsPathExists, + rules::flake8_use_pathlib::violations::OsPathExpanduser, + rules::flake8_use_pathlib::violations::OsPathIsdir, + rules::flake8_use_pathlib::violations::OsPathIsfile, + rules::flake8_use_pathlib::violations::OsPathIslink, + rules::flake8_use_pathlib::violations::OsReadlink, + rules::flake8_use_pathlib::violations::OsStat, + rules::flake8_use_pathlib::violations::OsPathIsabs, + rules::flake8_use_pathlib::violations::OsPathJoin, + rules::flake8_use_pathlib::violations::OsPathBasename, + rules::flake8_use_pathlib::violations::OsPathDirname, + rules::flake8_use_pathlib::violations::OsPathSamefile, + rules::flake8_use_pathlib::violations::OsPathSplitext, + rules::flake8_use_pathlib::violations::BuiltinOpen, + rules::flake8_use_pathlib::violations::PyPath, // flake8-logging-format rules::flake8_logging_format::violations::LoggingStringFormat, rules::flake8_logging_format::violations::LoggingPercentFormat, diff --git a/crates/ruff/src/rules/flake8_use_pathlib/helpers.rs b/crates/ruff/src/rules/flake8_use_pathlib/helpers.rs index eb3d542784..6d71a4c0a5 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/helpers.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/helpers.rs @@ -6,11 +6,10 @@ use ruff_python_ast::types::Range; use crate::checkers::ast::Checker; use crate::registry::AsRule; use crate::rules::flake8_use_pathlib::violations::{ - PathlibAbspath, PathlibBasename, PathlibChmod, PathlibDirname, PathlibExists, - PathlibExpanduser, PathlibGetcwd, PathlibIsAbs, PathlibIsDir, PathlibIsFile, PathlibIsLink, - PathlibJoin, PathlibMakedirs, PathlibMkdir, PathlibOpen, PathlibPyPath, PathlibReadlink, - PathlibRemove, PathlibRename, PathlibReplace, PathlibRmdir, PathlibSamefile, PathlibSplitext, - PathlibStat, PathlibUnlink, + BuiltinOpen, OsChmod, OsGetcwd, OsMakedirs, OsMkdir, OsPathAbspath, OsPathBasename, + OsPathDirname, OsPathExists, OsPathExpanduser, OsPathIsabs, OsPathIsdir, OsPathIsfile, + OsPathIslink, OsPathJoin, OsPathSamefile, OsPathSplitext, OsReadlink, OsRemove, OsRename, + OsRmdir, OsStat, OsUnlink, PathlibReplace, PyPath, }; use crate::settings::types::PythonVersion; @@ -20,34 +19,34 @@ pub fn replaceable_by_pathlib(checker: &mut Checker, expr: &Expr) { .ctx .resolve_call_path(expr) .and_then(|call_path| match call_path.as_slice() { - ["os", "path", "abspath"] => Some(PathlibAbspath.into()), - ["os", "chmod"] => Some(PathlibChmod.into()), - ["os", "mkdir"] => Some(PathlibMkdir.into()), - ["os", "makedirs"] => Some(PathlibMakedirs.into()), - ["os", "rename"] => Some(PathlibRename.into()), + ["os", "path", "abspath"] => Some(OsPathAbspath.into()), + ["os", "chmod"] => Some(OsChmod.into()), + ["os", "mkdir"] => Some(OsMkdir.into()), + ["os", "makedirs"] => Some(OsMakedirs.into()), + ["os", "rename"] => Some(OsRename.into()), ["os", "replace"] => Some(PathlibReplace.into()), - ["os", "rmdir"] => Some(PathlibRmdir.into()), - ["os", "remove"] => Some(PathlibRemove.into()), - ["os", "unlink"] => Some(PathlibUnlink.into()), - ["os", "getcwd"] => Some(PathlibGetcwd.into()), - ["os", "getcwdb"] => Some(PathlibGetcwd.into()), - ["os", "path", "exists"] => Some(PathlibExists.into()), - ["os", "path", "expanduser"] => Some(PathlibExpanduser.into()), - ["os", "path", "isdir"] => Some(PathlibIsDir.into()), - ["os", "path", "isfile"] => Some(PathlibIsFile.into()), - ["os", "path", "islink"] => Some(PathlibIsLink.into()), - ["os", "stat"] => Some(PathlibStat.into()), - ["os", "path", "isabs"] => Some(PathlibIsAbs.into()), - ["os", "path", "join"] => Some(PathlibJoin.into()), - ["os", "path", "basename"] => Some(PathlibBasename.into()), - ["os", "path", "dirname"] => Some(PathlibDirname.into()), - ["os", "path", "samefile"] => Some(PathlibSamefile.into()), - ["os", "path", "splitext"] => Some(PathlibSplitext.into()), - ["", "open"] => Some(PathlibOpen.into()), - ["py", "path", "local"] => Some(PathlibPyPath.into()), + ["os", "rmdir"] => Some(OsRmdir.into()), + ["os", "remove"] => Some(OsRemove.into()), + ["os", "unlink"] => Some(OsUnlink.into()), + ["os", "getcwd"] => Some(OsGetcwd.into()), + ["os", "getcwdb"] => Some(OsGetcwd.into()), + ["os", "path", "exists"] => Some(OsPathExists.into()), + ["os", "path", "expanduser"] => Some(OsPathExpanduser.into()), + ["os", "path", "isdir"] => Some(OsPathIsdir.into()), + ["os", "path", "isfile"] => Some(OsPathIsfile.into()), + ["os", "path", "islink"] => Some(OsPathIslink.into()), + ["os", "stat"] => Some(OsStat.into()), + ["os", "path", "isabs"] => Some(OsPathIsabs.into()), + ["os", "path", "join"] => Some(OsPathJoin.into()), + ["os", "path", "basename"] => Some(OsPathBasename.into()), + ["os", "path", "dirname"] => Some(OsPathDirname.into()), + ["os", "path", "samefile"] => Some(OsPathSamefile.into()), + ["os", "path", "splitext"] => Some(OsPathSplitext.into()), + ["", "open"] => Some(BuiltinOpen.into()), + ["py", "path", "local"] => Some(PyPath.into()), // Python 3.9+ ["os", "readlink"] if checker.settings.target_version >= PythonVersion::Py39 => { - Some(PathlibReadlink.into()) + Some(OsReadlink.into()) } _ => None, }) diff --git a/crates/ruff/src/rules/flake8_use_pathlib/mod.rs b/crates/ruff/src/rules/flake8_use_pathlib/mod.rs index 5aac0f9021..7c905e7d44 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/mod.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/mod.rs @@ -23,38 +23,38 @@ mod tests { let diagnostics = test_path( Path::new("flake8_use_pathlib").join(path).as_path(), &settings::Settings::for_rules(vec![ - Rule::PathlibAbspath, - Rule::PathlibChmod, - Rule::PathlibMkdir, - Rule::PathlibMakedirs, - Rule::PathlibRename, + Rule::OsPathAbspath, + Rule::OsChmod, + Rule::OsMkdir, + Rule::OsMakedirs, + Rule::OsRename, Rule::PathlibReplace, - Rule::PathlibRmdir, - Rule::PathlibRemove, - Rule::PathlibUnlink, - Rule::PathlibGetcwd, - Rule::PathlibExists, - Rule::PathlibExpanduser, - Rule::PathlibIsDir, - Rule::PathlibIsFile, - Rule::PathlibIsLink, - Rule::PathlibReadlink, - Rule::PathlibStat, - Rule::PathlibIsAbs, - Rule::PathlibJoin, - Rule::PathlibBasename, - Rule::PathlibDirname, - Rule::PathlibSamefile, - Rule::PathlibSplitext, - Rule::PathlibOpen, + Rule::OsRmdir, + Rule::OsRemove, + Rule::OsUnlink, + Rule::OsGetcwd, + Rule::OsPathExists, + Rule::OsPathExpanduser, + Rule::OsPathIsdir, + Rule::OsPathIsfile, + Rule::OsPathIslink, + Rule::OsReadlink, + Rule::OsStat, + Rule::OsPathIsabs, + Rule::OsPathJoin, + Rule::OsPathBasename, + Rule::OsPathDirname, + Rule::OsPathSamefile, + Rule::OsPathSplitext, + Rule::BuiltinOpen, ]), )?; insta::assert_yaml_snapshot!(snapshot, diagnostics); Ok(()) } - #[test_case(Rule::PathlibPyPath, 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_1.py"); "PTH024_1")] + #[test_case(Rule::PyPath, Path::new("py_path_2.py"); "PTH024_2")] fn rules_pypath(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap index e883d38ff7..539bfe4284 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibPyPath + name: PyPath body: "`py.path` is in maintenance mode, use `pathlib` instead" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap index 7a0304d1c0..9f887cff40 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibPyPath + name: PyPath body: "`py.path` is in maintenance mode, use `pathlib` instead" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap index 5d32cde4c1..0f472abf8f 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibAbspath + name: OsPathAbspath body: "`os.path.abspath()` should be replaced by `Path.resolve()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibChmod + name: OsChmod body: "`os.chmod()` should be replaced by `Path.chmod()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMkdir + name: OsMkdir body: "`os.mkdir()` should be replaced by `Path.mkdir()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMakedirs + name: OsMakedirs body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRename + name: OsRename body: "`os.rename()` should be replaced by `Path.rename()`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRmdir + name: OsRmdir body: "`os.rmdir()` should be replaced by `Path.rmdir()`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRemove + name: OsRemove body: "`os.remove()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibUnlink + name: OsUnlink body: "`os.unlink()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibGetcwd + name: OsGetcwd body: "`os.getcwd()` should be replaced by `Path.cwd()`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExists + name: OsPathExists body: "`os.path.exists()` should be replaced by `Path.exists()`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExpanduser + name: OsPathExpanduser body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsDir + name: OsPathIsdir body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsFile + name: OsPathIsfile body: "`os.path.isfile()` should be replaced by `Path.is_file()`" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsLink + name: OsPathIslink body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibReadlink + name: OsReadlink body: "`os.readlink()` should be replaced by `Path.readlink()`" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibStat + name: OsStat body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsAbs + name: OsPathIsabs body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibJoin + name: OsPathJoin body: "`os.path.join()` should be replaced by `Path` with `/` operator" suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibBasename + name: OsPathBasename body: "`os.path.basename()` should be replaced by `Path.name`" suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibDirname + name: OsPathDirname body: "`os.path.dirname()` should be replaced by `Path.parent`" suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSamefile + name: OsPathSamefile body: "`os.path.samefile()` should be replaced by `Path.samefile()`" suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSplitext + name: OsPathSplitext body: "`os.path.splitext()` should be replaced by `Path.suffix`" suggestion: ~ fixable: false @@ -302,7 +302,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibOpen + name: BuiltinOpen body: "`open()` should be replaced by `Path.open()`" suggestion: ~ fixable: false @@ -315,7 +315,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibOpen + name: BuiltinOpen body: "`open()` should be replaced by `Path.open()`" suggestion: ~ fixable: false @@ -328,7 +328,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibGetcwd + name: OsGetcwd body: "`os.getcwd()` should be replaced by `Path.cwd()`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap index 64057ab7ea..53ffbb4d75 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibAbspath + name: OsPathAbspath body: "`os.path.abspath()` should be replaced by `Path.resolve()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibChmod + name: OsChmod body: "`os.chmod()` should be replaced by `Path.chmod()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMkdir + name: OsMkdir body: "`os.mkdir()` should be replaced by `Path.mkdir()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMakedirs + name: OsMakedirs body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRename + name: OsRename body: "`os.rename()` should be replaced by `Path.rename()`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRmdir + name: OsRmdir body: "`os.rmdir()` should be replaced by `Path.rmdir()`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRemove + name: OsRemove body: "`os.remove()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibUnlink + name: OsUnlink body: "`os.unlink()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibGetcwd + name: OsGetcwd body: "`os.getcwd()` should be replaced by `Path.cwd()`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExists + name: OsPathExists body: "`os.path.exists()` should be replaced by `Path.exists()`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExpanduser + name: OsPathExpanduser body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsDir + name: OsPathIsdir body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsFile + name: OsPathIsfile body: "`os.path.isfile()` should be replaced by `Path.is_file()`" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsLink + name: OsPathIslink body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibReadlink + name: OsReadlink body: "`os.readlink()` should be replaced by `Path.readlink()`" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibStat + name: OsStat body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsAbs + name: OsPathIsabs body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibJoin + name: OsPathJoin body: "`os.path.join()` should be replaced by `Path` with `/` operator" suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibBasename + name: OsPathBasename body: "`os.path.basename()` should be replaced by `Path.name`" suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibDirname + name: OsPathDirname body: "`os.path.dirname()` should be replaced by `Path.parent`" suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSamefile + name: OsPathSamefile body: "`os.path.samefile()` should be replaced by `Path.samefile()`" suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSplitext + name: OsPathSplitext body: "`os.path.splitext()` should be replaced by `Path.suffix`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap index 541fd2c703..51d1698e32 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibAbspath + name: OsPathAbspath body: "`os.path.abspath()` should be replaced by `Path.resolve()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibChmod + name: OsChmod body: "`os.chmod()` should be replaced by `Path.chmod()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMkdir + name: OsMkdir body: "`os.mkdir()` should be replaced by `Path.mkdir()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMakedirs + name: OsMakedirs body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRename + name: OsRename body: "`os.rename()` should be replaced by `Path.rename()`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRmdir + name: OsRmdir body: "`os.rmdir()` should be replaced by `Path.rmdir()`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRemove + name: OsRemove body: "`os.remove()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibUnlink + name: OsUnlink body: "`os.unlink()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibGetcwd + name: OsGetcwd body: "`os.getcwd()` should be replaced by `Path.cwd()`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExists + name: OsPathExists body: "`os.path.exists()` should be replaced by `Path.exists()`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExpanduser + name: OsPathExpanduser body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsDir + name: OsPathIsdir body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsFile + name: OsPathIsfile body: "`os.path.isfile()` should be replaced by `Path.is_file()`" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsLink + name: OsPathIslink body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibReadlink + name: OsReadlink body: "`os.readlink()` should be replaced by `Path.readlink()`" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibStat + name: OsStat body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsAbs + name: OsPathIsabs body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibJoin + name: OsPathJoin body: "`os.path.join()` should be replaced by `Path` with `/` operator" suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibBasename + name: OsPathBasename body: "`os.path.basename()` should be replaced by `Path.name`" suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibDirname + name: OsPathDirname body: "`os.path.dirname()` should be replaced by `Path.parent`" suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSamefile + name: OsPathSamefile body: "`os.path.samefile()` should be replaced by `Path.samefile()`" suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSplitext + name: OsPathSplitext body: "`os.path.splitext()` should be replaced by `Path.suffix`" suggestion: ~ fixable: false @@ -302,7 +302,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibOpen + name: BuiltinOpen body: "`open()` should be replaced by `Path.open()`" suggestion: ~ fixable: false @@ -315,7 +315,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibOpen + name: BuiltinOpen body: "`open()` should be replaced by `Path.open()`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap index ea0848b8b3..27a7f29dc4 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap +++ b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs expression: diagnostics --- - kind: - name: PathlibAbspath + name: OsPathAbspath body: "`os.path.abspath()` should be replaced by `Path.resolve()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibChmod + name: OsChmod body: "`os.chmod()` should be replaced by `Path.chmod()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMkdir + name: OsMkdir body: "`os.mkdir()` should be replaced by `Path.mkdir()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibMakedirs + name: OsMakedirs body: "`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRename + name: OsRename body: "`os.rename()` should be replaced by `Path.rename()`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRmdir + name: OsRmdir body: "`os.rmdir()` should be replaced by `Path.rmdir()`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibRemove + name: OsRemove body: "`os.remove()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibUnlink + name: OsUnlink body: "`os.unlink()` should be replaced by `Path.unlink()`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibGetcwd + name: OsGetcwd body: "`os.getcwd()` should be replaced by `Path.cwd()`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExists + name: OsPathExists body: "`os.path.exists()` should be replaced by `Path.exists()`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibExpanduser + name: OsPathExpanduser body: "`os.path.expanduser()` should be replaced by `Path.expanduser()`" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsDir + name: OsPathIsdir body: "`os.path.isdir()` should be replaced by `Path.is_dir()`" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsFile + name: OsPathIsfile body: "`os.path.isfile()` should be replaced by `Path.is_file()`" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsLink + name: OsPathIslink body: "`os.path.islink()` should be replaced by `Path.is_symlink()`" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibReadlink + name: OsReadlink body: "`os.readlink()` should be replaced by `Path.readlink()`" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibStat + name: OsStat body: "`os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`" suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibIsAbs + name: OsPathIsabs body: "`os.path.isabs()` should be replaced by `Path.is_absolute()`" suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibJoin + name: OsPathJoin body: "`os.path.join()` should be replaced by `Path` with `/` operator" suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibBasename + name: OsPathBasename body: "`os.path.basename()` should be replaced by `Path.name`" suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibDirname + name: OsPathDirname body: "`os.path.dirname()` should be replaced by `Path.parent`" suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSamefile + name: OsPathSamefile body: "`os.path.samefile()` should be replaced by `Path.samefile()`" suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PathlibSplitext + name: OsPathSplitext body: "`os.path.splitext()` should be replaced by `Path.suffix`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_use_pathlib/violations.rs b/crates/ruff/src/rules/flake8_use_pathlib/violations.rs index 03399e849c..d80fc99308 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/violations.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/violations.rs @@ -3,9 +3,9 @@ use ruff_macros::{derive_message_formats, violation}; // PTH100 #[violation] -pub struct PathlibAbspath; +pub struct OsPathAbspath; -impl Violation for PathlibAbspath { +impl Violation for OsPathAbspath { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.abspath()` should be replaced by `Path.resolve()`") @@ -14,9 +14,9 @@ impl Violation for PathlibAbspath { // PTH101 #[violation] -pub struct PathlibChmod; +pub struct OsChmod; -impl Violation for PathlibChmod { +impl Violation for OsChmod { #[derive_message_formats] fn message(&self) -> String { format!("`os.chmod()` should be replaced by `Path.chmod()`") @@ -25,9 +25,9 @@ impl Violation for PathlibChmod { // PTH102 #[violation] -pub struct PathlibMakedirs; +pub struct OsMakedirs; -impl Violation for PathlibMakedirs { +impl Violation for OsMakedirs { #[derive_message_formats] fn message(&self) -> String { format!("`os.makedirs()` should be replaced by `Path.mkdir(parents=True)`") @@ -36,9 +36,9 @@ impl Violation for PathlibMakedirs { // PTH103 #[violation] -pub struct PathlibMkdir; +pub struct OsMkdir; -impl Violation for PathlibMkdir { +impl Violation for OsMkdir { #[derive_message_formats] fn message(&self) -> String { format!("`os.mkdir()` should be replaced by `Path.mkdir()`") @@ -47,9 +47,9 @@ impl Violation for PathlibMkdir { // PTH104 #[violation] -pub struct PathlibRename; +pub struct OsRename; -impl Violation for PathlibRename { +impl Violation for OsRename { #[derive_message_formats] fn message(&self) -> String { format!("`os.rename()` should be replaced by `Path.rename()`") @@ -69,9 +69,9 @@ impl Violation for PathlibReplace { // PTH106 #[violation] -pub struct PathlibRmdir; +pub struct OsRmdir; -impl Violation for PathlibRmdir { +impl Violation for OsRmdir { #[derive_message_formats] fn message(&self) -> String { format!("`os.rmdir()` should be replaced by `Path.rmdir()`") @@ -80,9 +80,9 @@ impl Violation for PathlibRmdir { // PTH107 #[violation] -pub struct PathlibRemove; +pub struct OsRemove; -impl Violation for PathlibRemove { +impl Violation for OsRemove { #[derive_message_formats] fn message(&self) -> String { format!("`os.remove()` should be replaced by `Path.unlink()`") @@ -91,9 +91,9 @@ impl Violation for PathlibRemove { // PTH108 #[violation] -pub struct PathlibUnlink; +pub struct OsUnlink; -impl Violation for PathlibUnlink { +impl Violation for OsUnlink { #[derive_message_formats] fn message(&self) -> String { format!("`os.unlink()` should be replaced by `Path.unlink()`") @@ -102,9 +102,9 @@ impl Violation for PathlibUnlink { // PTH109 #[violation] -pub struct PathlibGetcwd; +pub struct OsGetcwd; -impl Violation for PathlibGetcwd { +impl Violation for OsGetcwd { #[derive_message_formats] fn message(&self) -> String { format!("`os.getcwd()` should be replaced by `Path.cwd()`") @@ -113,9 +113,9 @@ impl Violation for PathlibGetcwd { // PTH110 #[violation] -pub struct PathlibExists; +pub struct OsPathExists; -impl Violation for PathlibExists { +impl Violation for OsPathExists { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.exists()` should be replaced by `Path.exists()`") @@ -124,9 +124,9 @@ impl Violation for PathlibExists { // PTH111 #[violation] -pub struct PathlibExpanduser; +pub struct OsPathExpanduser; -impl Violation for PathlibExpanduser { +impl Violation for OsPathExpanduser { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.expanduser()` should be replaced by `Path.expanduser()`") @@ -135,9 +135,9 @@ impl Violation for PathlibExpanduser { // PTH112 #[violation] -pub struct PathlibIsDir; +pub struct OsPathIsdir; -impl Violation for PathlibIsDir { +impl Violation for OsPathIsdir { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.isdir()` should be replaced by `Path.is_dir()`") @@ -146,9 +146,9 @@ impl Violation for PathlibIsDir { // PTH113 #[violation] -pub struct PathlibIsFile; +pub struct OsPathIsfile; -impl Violation for PathlibIsFile { +impl Violation for OsPathIsfile { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.isfile()` should be replaced by `Path.is_file()`") @@ -157,9 +157,9 @@ impl Violation for PathlibIsFile { // PTH114 #[violation] -pub struct PathlibIsLink; +pub struct OsPathIslink; -impl Violation for PathlibIsLink { +impl Violation for OsPathIslink { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.islink()` should be replaced by `Path.is_symlink()`") @@ -168,9 +168,9 @@ impl Violation for PathlibIsLink { // PTH115 #[violation] -pub struct PathlibReadlink; +pub struct OsReadlink; -impl Violation for PathlibReadlink { +impl Violation for OsReadlink { #[derive_message_formats] fn message(&self) -> String { format!("`os.readlink()` should be replaced by `Path.readlink()`") @@ -179,9 +179,9 @@ impl Violation for PathlibReadlink { // PTH116 #[violation] -pub struct PathlibStat; +pub struct OsStat; -impl Violation for PathlibStat { +impl Violation for OsStat { #[derive_message_formats] fn message(&self) -> String { format!( @@ -192,9 +192,9 @@ impl Violation for PathlibStat { // PTH117 #[violation] -pub struct PathlibIsAbs; +pub struct OsPathIsabs; -impl Violation for PathlibIsAbs { +impl Violation for OsPathIsabs { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.isabs()` should be replaced by `Path.is_absolute()`") @@ -203,9 +203,9 @@ impl Violation for PathlibIsAbs { // PTH118 #[violation] -pub struct PathlibJoin; +pub struct OsPathJoin; -impl Violation for PathlibJoin { +impl Violation for OsPathJoin { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.join()` should be replaced by `Path` with `/` operator") @@ -214,9 +214,9 @@ impl Violation for PathlibJoin { // PTH119 #[violation] -pub struct PathlibBasename; +pub struct OsPathBasename; -impl Violation for PathlibBasename { +impl Violation for OsPathBasename { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.basename()` should be replaced by `Path.name`") @@ -225,9 +225,9 @@ impl Violation for PathlibBasename { // PTH120 #[violation] -pub struct PathlibDirname; +pub struct OsPathDirname; -impl Violation for PathlibDirname { +impl Violation for OsPathDirname { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.dirname()` should be replaced by `Path.parent`") @@ -236,9 +236,9 @@ impl Violation for PathlibDirname { // PTH121 #[violation] -pub struct PathlibSamefile; +pub struct OsPathSamefile; -impl Violation for PathlibSamefile { +impl Violation for OsPathSamefile { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.samefile()` should be replaced by `Path.samefile()`") @@ -247,9 +247,9 @@ impl Violation for PathlibSamefile { // PTH122 #[violation] -pub struct PathlibSplitext; +pub struct OsPathSplitext; -impl Violation for PathlibSplitext { +impl Violation for OsPathSplitext { #[derive_message_formats] fn message(&self) -> String { format!("`os.path.splitext()` should be replaced by `Path.suffix`") @@ -258,9 +258,9 @@ impl Violation for PathlibSplitext { // PTH123 #[violation] -pub struct PathlibOpen; +pub struct BuiltinOpen; -impl Violation for PathlibOpen { +impl Violation for BuiltinOpen { #[derive_message_formats] fn message(&self) -> String { format!("`open()` should be replaced by `Path.open()`") @@ -269,9 +269,9 @@ impl Violation for PathlibOpen { // PTH124 #[violation] -pub struct PathlibPyPath; +pub struct PyPath; -impl Violation for PathlibPyPath { +impl Violation for PyPath { #[derive_message_formats] fn message(&self) -> String { format!("`py.path` is in maintenance mode, use `pathlib` instead")