mirror of https://github.com/astral-sh/ruff
[`flake8-use-pathlib`] extend PTH118 with `os.sep` (#5935)
Closes https://github.com/astral-sh/ruff/issues/5905 Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
d62183b07d
commit
f7b156523a
|
|
@ -2,6 +2,7 @@ import os
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
p = "/foo"
|
p = "/foo"
|
||||||
|
q = "bar"
|
||||||
|
|
||||||
a = os.path.abspath(p)
|
a = os.path.abspath(p)
|
||||||
aa = os.chmod(p)
|
aa = os.chmod(p)
|
||||||
|
|
@ -21,7 +22,9 @@ bbbbb = os.path.islink(p)
|
||||||
os.readlink(p)
|
os.readlink(p)
|
||||||
os.stat(p)
|
os.stat(p)
|
||||||
os.path.isabs(p)
|
os.path.isabs(p)
|
||||||
os.path.join(p)
|
os.path.join(p, q)
|
||||||
|
os.sep.join([p, q])
|
||||||
|
os.sep.join((p, q))
|
||||||
os.path.basename(p)
|
os.path.basename(p)
|
||||||
os.path.dirname(p)
|
os.path.dirname(p)
|
||||||
os.path.samefile(p)
|
os.path.samefile(p)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import os as foo
|
||||||
import os.path as foo_p
|
import os.path as foo_p
|
||||||
|
|
||||||
p = "/foo"
|
p = "/foo"
|
||||||
|
q = "bar"
|
||||||
|
|
||||||
a = foo_p.abspath(p)
|
a = foo_p.abspath(p)
|
||||||
aa = foo.chmod(p)
|
aa = foo.chmod(p)
|
||||||
|
|
@ -21,7 +22,9 @@ bbbbb = foo_p.islink(p)
|
||||||
foo.readlink(p)
|
foo.readlink(p)
|
||||||
foo.stat(p)
|
foo.stat(p)
|
||||||
foo_p.isabs(p)
|
foo_p.isabs(p)
|
||||||
foo_p.join(p)
|
foo_p.join(p, q)
|
||||||
|
foo.sep.join([p, q])
|
||||||
|
foo.sep.join((p, q))
|
||||||
foo_p.basename(p)
|
foo_p.basename(p)
|
||||||
foo_p.dirname(p)
|
foo_p.dirname(p)
|
||||||
foo_p.samefile(p)
|
foo_p.samefile(p)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
from os import chmod, mkdir, makedirs, rename, replace, rmdir
|
from os import chmod, mkdir, makedirs, rename, replace, rmdir, sep
|
||||||
from os import remove, unlink, getcwd, readlink, stat
|
from os import remove, unlink, getcwd, readlink, stat
|
||||||
from os.path import abspath, exists, expanduser, isdir, isfile, islink
|
from os.path import abspath, exists, expanduser, isdir, isfile, islink
|
||||||
from os.path import isabs, join, basename, dirname, samefile, splitext
|
from os.path import isabs, join, basename, dirname, samefile, splitext
|
||||||
|
|
||||||
p = "/foo"
|
p = "/foo"
|
||||||
|
q = "bar"
|
||||||
|
|
||||||
a = abspath(p)
|
a = abspath(p)
|
||||||
aa = chmod(p)
|
aa = chmod(p)
|
||||||
|
|
@ -23,7 +24,9 @@ bbbbb = islink(p)
|
||||||
readlink(p)
|
readlink(p)
|
||||||
stat(p)
|
stat(p)
|
||||||
isabs(p)
|
isabs(p)
|
||||||
join(p)
|
join(p, q)
|
||||||
|
sep.join((p, q))
|
||||||
|
sep.join([p, q])
|
||||||
basename(p)
|
basename(p)
|
||||||
dirname(p)
|
dirname(p)
|
||||||
samefile(p)
|
samefile(p)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from os import chmod as xchmod, mkdir as xmkdir
|
from os import chmod as xchmod, mkdir as xmkdir, sep as s
|
||||||
from os import makedirs as xmakedirs, rename as xrename, replace as xreplace
|
from os import makedirs as xmakedirs, rename as xrename, replace as xreplace
|
||||||
from os import rmdir as xrmdir, remove as xremove, unlink as xunlink
|
from os import rmdir as xrmdir, remove as xremove, unlink as xunlink
|
||||||
from os import getcwd as xgetcwd, readlink as xreadlink, stat as xstat
|
from os import getcwd as xgetcwd, readlink as xreadlink, stat as xstat
|
||||||
|
|
@ -9,6 +9,7 @@ from os.path import join as xjoin, basename as xbasename, dirname as xdirname
|
||||||
from os.path import samefile as xsamefile, splitext as xsplitext
|
from os.path import samefile as xsamefile, splitext as xsplitext
|
||||||
|
|
||||||
p = "/foo"
|
p = "/foo"
|
||||||
|
q = "bar"
|
||||||
|
|
||||||
a = xabspath(p)
|
a = xabspath(p)
|
||||||
aa = xchmod(p)
|
aa = xchmod(p)
|
||||||
|
|
@ -28,7 +29,9 @@ bbbbb = xislink(p)
|
||||||
xreadlink(p)
|
xreadlink(p)
|
||||||
xstat(p)
|
xstat(p)
|
||||||
xisabs(p)
|
xisabs(p)
|
||||||
xjoin(p)
|
xjoin(p, q)
|
||||||
|
s.join((p, q))
|
||||||
|
s.join([p, q])
|
||||||
xbasename(p)
|
xbasename(p)
|
||||||
xdirname(p)
|
xdirname(p)
|
||||||
xsamefile(p)
|
xsamefile(p)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,18 @@ pub(crate) fn replaceable_by_pathlib(checker: &mut Checker, expr: &Expr) {
|
||||||
// PTH117
|
// PTH117
|
||||||
["os", "path", "isabs"] => Some(OsPathIsabs.into()),
|
["os", "path", "isabs"] => Some(OsPathIsabs.into()),
|
||||||
// PTH118
|
// PTH118
|
||||||
["os", "path", "join"] => Some(OsPathJoin.into()),
|
["os", "path", "join"] => Some(
|
||||||
|
OsPathJoin {
|
||||||
|
module: "path".to_string(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
),
|
||||||
|
["os", "sep", "join"] => Some(
|
||||||
|
OsPathJoin {
|
||||||
|
module: "sep".to_string(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
),
|
||||||
// PTH119
|
// PTH119
|
||||||
["os", "path", "basename"] => Some(OsPathBasename.into()),
|
["os", "path", "basename"] => Some(OsPathBasename.into()),
|
||||||
// PTH120
|
// PTH120
|
||||||
|
|
|
||||||
|
|
@ -1,259 +1,279 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
||||||
---
|
---
|
||||||
full_name.py:6:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
full_name.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||||
|
|
|
|
||||||
4 | p = "/foo"
|
5 | q = "bar"
|
||||||
5 |
|
6 |
|
||||||
6 | a = os.path.abspath(p)
|
7 | a = os.path.abspath(p)
|
||||||
| ^^^^^^^^^^^^^^^ PTH100
|
| ^^^^^^^^^^^^^^^ PTH100
|
||||||
7 | aa = os.chmod(p)
|
8 | aa = os.chmod(p)
|
||||||
8 | aaa = os.mkdir(p)
|
9 | aaa = os.mkdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:7:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
full_name.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
||||||
|
|
|
|
||||||
6 | a = os.path.abspath(p)
|
7 | a = os.path.abspath(p)
|
||||||
7 | aa = os.chmod(p)
|
8 | aa = os.chmod(p)
|
||||||
| ^^^^^^^^ PTH101
|
| ^^^^^^^^ PTH101
|
||||||
8 | aaa = os.mkdir(p)
|
9 | aaa = os.mkdir(p)
|
||||||
9 | os.makedirs(p)
|
10 | os.makedirs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:8:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
full_name.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
||||||
|
|
|
|
||||||
6 | a = os.path.abspath(p)
|
7 | a = os.path.abspath(p)
|
||||||
7 | aa = os.chmod(p)
|
8 | aa = os.chmod(p)
|
||||||
8 | aaa = os.mkdir(p)
|
9 | aaa = os.mkdir(p)
|
||||||
| ^^^^^^^^ PTH102
|
| ^^^^^^^^ PTH102
|
||||||
9 | os.makedirs(p)
|
10 | os.makedirs(p)
|
||||||
10 | os.rename(p)
|
11 | os.rename(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:9:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
full_name.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
||||||
|
|
|
|
||||||
7 | aa = os.chmod(p)
|
8 | aa = os.chmod(p)
|
||||||
8 | aaa = os.mkdir(p)
|
9 | aaa = os.mkdir(p)
|
||||||
9 | os.makedirs(p)
|
10 | os.makedirs(p)
|
||||||
| ^^^^^^^^^^^ PTH103
|
| ^^^^^^^^^^^ PTH103
|
||||||
10 | os.rename(p)
|
11 | os.rename(p)
|
||||||
11 | os.replace(p)
|
12 | os.replace(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:10:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
full_name.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
||||||
|
|
|
|
||||||
8 | aaa = os.mkdir(p)
|
9 | aaa = os.mkdir(p)
|
||||||
9 | os.makedirs(p)
|
10 | os.makedirs(p)
|
||||||
10 | os.rename(p)
|
11 | os.rename(p)
|
||||||
| ^^^^^^^^^ PTH104
|
| ^^^^^^^^^ PTH104
|
||||||
11 | os.replace(p)
|
12 | os.replace(p)
|
||||||
12 | os.rmdir(p)
|
13 | os.rmdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:11:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
full_name.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
||||||
|
|
|
|
||||||
9 | os.makedirs(p)
|
10 | os.makedirs(p)
|
||||||
10 | os.rename(p)
|
11 | os.rename(p)
|
||||||
11 | os.replace(p)
|
12 | os.replace(p)
|
||||||
| ^^^^^^^^^^ PTH105
|
| ^^^^^^^^^^ PTH105
|
||||||
12 | os.rmdir(p)
|
13 | os.rmdir(p)
|
||||||
13 | os.remove(p)
|
14 | os.remove(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:12:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
full_name.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
||||||
|
|
|
|
||||||
10 | os.rename(p)
|
11 | os.rename(p)
|
||||||
11 | os.replace(p)
|
12 | os.replace(p)
|
||||||
12 | os.rmdir(p)
|
13 | os.rmdir(p)
|
||||||
| ^^^^^^^^ PTH106
|
| ^^^^^^^^ PTH106
|
||||||
13 | os.remove(p)
|
14 | os.remove(p)
|
||||||
14 | os.unlink(p)
|
15 | os.unlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:13:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
full_name.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
11 | os.replace(p)
|
12 | os.replace(p)
|
||||||
12 | os.rmdir(p)
|
13 | os.rmdir(p)
|
||||||
13 | os.remove(p)
|
14 | os.remove(p)
|
||||||
| ^^^^^^^^^ PTH107
|
| ^^^^^^^^^ PTH107
|
||||||
14 | os.unlink(p)
|
15 | os.unlink(p)
|
||||||
15 | os.getcwd(p)
|
16 | os.getcwd(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:14:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
full_name.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
12 | os.rmdir(p)
|
13 | os.rmdir(p)
|
||||||
13 | os.remove(p)
|
14 | os.remove(p)
|
||||||
14 | os.unlink(p)
|
15 | os.unlink(p)
|
||||||
| ^^^^^^^^^ PTH108
|
| ^^^^^^^^^ PTH108
|
||||||
15 | os.getcwd(p)
|
16 | os.getcwd(p)
|
||||||
16 | b = os.path.exists(p)
|
17 | b = os.path.exists(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:15:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
full_name.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
||||||
|
|
|
|
||||||
13 | os.remove(p)
|
14 | os.remove(p)
|
||||||
14 | os.unlink(p)
|
15 | os.unlink(p)
|
||||||
15 | os.getcwd(p)
|
16 | os.getcwd(p)
|
||||||
| ^^^^^^^^^ PTH109
|
| ^^^^^^^^^ PTH109
|
||||||
16 | b = os.path.exists(p)
|
17 | b = os.path.exists(p)
|
||||||
17 | bb = os.path.expanduser(p)
|
18 | bb = os.path.expanduser(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:16:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
full_name.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
||||||
|
|
|
|
||||||
14 | os.unlink(p)
|
15 | os.unlink(p)
|
||||||
15 | os.getcwd(p)
|
16 | os.getcwd(p)
|
||||||
16 | b = os.path.exists(p)
|
17 | b = os.path.exists(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH110
|
| ^^^^^^^^^^^^^^ PTH110
|
||||||
17 | bb = os.path.expanduser(p)
|
18 | bb = os.path.expanduser(p)
|
||||||
18 | bbb = os.path.isdir(p)
|
19 | bbb = os.path.isdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:17:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
full_name.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
||||||
|
|
|
|
||||||
15 | os.getcwd(p)
|
16 | os.getcwd(p)
|
||||||
16 | b = os.path.exists(p)
|
17 | b = os.path.exists(p)
|
||||||
17 | bb = os.path.expanduser(p)
|
18 | bb = os.path.expanduser(p)
|
||||||
| ^^^^^^^^^^^^^^^^^^ PTH111
|
| ^^^^^^^^^^^^^^^^^^ PTH111
|
||||||
18 | bbb = os.path.isdir(p)
|
19 | bbb = os.path.isdir(p)
|
||||||
19 | bbbb = os.path.isfile(p)
|
20 | bbbb = os.path.isfile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:18:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
full_name.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
||||||
|
|
|
|
||||||
16 | b = os.path.exists(p)
|
17 | b = os.path.exists(p)
|
||||||
17 | bb = os.path.expanduser(p)
|
18 | bb = os.path.expanduser(p)
|
||||||
18 | bbb = os.path.isdir(p)
|
19 | bbb = os.path.isdir(p)
|
||||||
| ^^^^^^^^^^^^^ PTH112
|
| ^^^^^^^^^^^^^ PTH112
|
||||||
19 | bbbb = os.path.isfile(p)
|
20 | bbbb = os.path.isfile(p)
|
||||||
20 | bbbbb = os.path.islink(p)
|
21 | bbbbb = os.path.islink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:19:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
full_name.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||||
|
|
|
|
||||||
17 | bb = os.path.expanduser(p)
|
18 | bb = os.path.expanduser(p)
|
||||||
18 | bbb = os.path.isdir(p)
|
19 | bbb = os.path.isdir(p)
|
||||||
19 | bbbb = os.path.isfile(p)
|
20 | bbbb = os.path.isfile(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH113
|
| ^^^^^^^^^^^^^^ PTH113
|
||||||
20 | bbbbb = os.path.islink(p)
|
21 | bbbbb = os.path.islink(p)
|
||||||
21 | os.readlink(p)
|
22 | os.readlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:20:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
full_name.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
||||||
|
|
|
|
||||||
18 | bbb = os.path.isdir(p)
|
19 | bbb = os.path.isdir(p)
|
||||||
19 | bbbb = os.path.isfile(p)
|
20 | bbbb = os.path.isfile(p)
|
||||||
20 | bbbbb = os.path.islink(p)
|
21 | bbbbb = os.path.islink(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH114
|
| ^^^^^^^^^^^^^^ PTH114
|
||||||
21 | os.readlink(p)
|
22 | os.readlink(p)
|
||||||
22 | os.stat(p)
|
23 | os.stat(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:21:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
full_name.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
||||||
|
|
|
|
||||||
19 | bbbb = os.path.isfile(p)
|
20 | bbbb = os.path.isfile(p)
|
||||||
20 | bbbbb = os.path.islink(p)
|
21 | bbbbb = os.path.islink(p)
|
||||||
21 | os.readlink(p)
|
22 | os.readlink(p)
|
||||||
| ^^^^^^^^^^^ PTH115
|
| ^^^^^^^^^^^ PTH115
|
||||||
22 | os.stat(p)
|
23 | os.stat(p)
|
||||||
23 | os.path.isabs(p)
|
24 | os.path.isabs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:22:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
full_name.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
||||||
|
|
|
|
||||||
20 | bbbbb = os.path.islink(p)
|
21 | bbbbb = os.path.islink(p)
|
||||||
21 | os.readlink(p)
|
22 | os.readlink(p)
|
||||||
22 | os.stat(p)
|
23 | os.stat(p)
|
||||||
| ^^^^^^^ PTH116
|
| ^^^^^^^ PTH116
|
||||||
23 | os.path.isabs(p)
|
24 | os.path.isabs(p)
|
||||||
24 | os.path.join(p)
|
25 | os.path.join(p, q)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:23:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
full_name.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
||||||
|
|
|
|
||||||
21 | os.readlink(p)
|
22 | os.readlink(p)
|
||||||
22 | os.stat(p)
|
23 | os.stat(p)
|
||||||
23 | os.path.isabs(p)
|
24 | os.path.isabs(p)
|
||||||
| ^^^^^^^^^^^^^ PTH117
|
| ^^^^^^^^^^^^^ PTH117
|
||||||
24 | os.path.join(p)
|
25 | os.path.join(p, q)
|
||||||
25 | os.path.basename(p)
|
26 | os.sep.join([p, q])
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:24:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
full_name.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
22 | os.stat(p)
|
23 | os.stat(p)
|
||||||
23 | os.path.isabs(p)
|
24 | os.path.isabs(p)
|
||||||
24 | os.path.join(p)
|
25 | os.path.join(p, q)
|
||||||
| ^^^^^^^^^^^^ PTH118
|
| ^^^^^^^^^^^^ PTH118
|
||||||
25 | os.path.basename(p)
|
26 | os.sep.join([p, q])
|
||||||
26 | os.path.dirname(p)
|
27 | os.sep.join((p, q))
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:25:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
full_name.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
23 | os.path.isabs(p)
|
24 | os.path.isabs(p)
|
||||||
24 | os.path.join(p)
|
25 | os.path.join(p, q)
|
||||||
25 | os.path.basename(p)
|
26 | os.sep.join([p, q])
|
||||||
|
| ^^^^^^^^^^^ PTH118
|
||||||
|
27 | os.sep.join((p, q))
|
||||||
|
28 | os.path.basename(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
full_name.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
||||||
|
25 | os.path.join(p, q)
|
||||||
|
26 | os.sep.join([p, q])
|
||||||
|
27 | os.sep.join((p, q))
|
||||||
|
| ^^^^^^^^^^^ PTH118
|
||||||
|
28 | os.path.basename(p)
|
||||||
|
29 | os.path.dirname(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
full_name.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
||||||
|
|
|
||||||
|
26 | os.sep.join([p, q])
|
||||||
|
27 | os.sep.join((p, q))
|
||||||
|
28 | os.path.basename(p)
|
||||||
| ^^^^^^^^^^^^^^^^ PTH119
|
| ^^^^^^^^^^^^^^^^ PTH119
|
||||||
26 | os.path.dirname(p)
|
29 | os.path.dirname(p)
|
||||||
27 | os.path.samefile(p)
|
30 | os.path.samefile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:26:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
full_name.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
||||||
|
|
|
|
||||||
24 | os.path.join(p)
|
27 | os.sep.join((p, q))
|
||||||
25 | os.path.basename(p)
|
28 | os.path.basename(p)
|
||||||
26 | os.path.dirname(p)
|
29 | os.path.dirname(p)
|
||||||
| ^^^^^^^^^^^^^^^ PTH120
|
| ^^^^^^^^^^^^^^^ PTH120
|
||||||
27 | os.path.samefile(p)
|
30 | os.path.samefile(p)
|
||||||
28 | os.path.splitext(p)
|
31 | os.path.splitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:27:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
full_name.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
||||||
|
|
|
|
||||||
25 | os.path.basename(p)
|
28 | os.path.basename(p)
|
||||||
26 | os.path.dirname(p)
|
29 | os.path.dirname(p)
|
||||||
27 | os.path.samefile(p)
|
30 | os.path.samefile(p)
|
||||||
| ^^^^^^^^^^^^^^^^ PTH121
|
| ^^^^^^^^^^^^^^^^ PTH121
|
||||||
28 | os.path.splitext(p)
|
31 | os.path.splitext(p)
|
||||||
29 | with open(p) as fp:
|
32 | with open(p) as fp:
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:28:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
full_name.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
||||||
|
|
|
|
||||||
26 | os.path.dirname(p)
|
29 | os.path.dirname(p)
|
||||||
27 | os.path.samefile(p)
|
30 | os.path.samefile(p)
|
||||||
28 | os.path.splitext(p)
|
31 | os.path.splitext(p)
|
||||||
| ^^^^^^^^^^^^^^^^ PTH122
|
| ^^^^^^^^^^^^^^^^ PTH122
|
||||||
29 | with open(p) as fp:
|
32 | with open(p) as fp:
|
||||||
30 | fp.read()
|
33 | fp.read()
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:29:6: PTH123 `open()` should be replaced by `Path.open()`
|
full_name.py:32:6: PTH123 `open()` should be replaced by `Path.open()`
|
||||||
|
|
|
|
||||||
27 | os.path.samefile(p)
|
30 | os.path.samefile(p)
|
||||||
28 | os.path.splitext(p)
|
31 | os.path.splitext(p)
|
||||||
29 | with open(p) as fp:
|
32 | with open(p) as fp:
|
||||||
| ^^^^ PTH123
|
| ^^^^ PTH123
|
||||||
30 | fp.read()
|
33 | fp.read()
|
||||||
31 | open(p).close()
|
34 | open(p).close()
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:31:1: PTH123 `open()` should be replaced by `Path.open()`
|
full_name.py:34:1: PTH123 `open()` should be replaced by `Path.open()`
|
||||||
|
|
|
|
||||||
29 | with open(p) as fp:
|
32 | with open(p) as fp:
|
||||||
30 | fp.read()
|
33 | fp.read()
|
||||||
31 | open(p).close()
|
34 | open(p).close()
|
||||||
| ^^^^ PTH123
|
| ^^^^ PTH123
|
||||||
32 | os.getcwdb(p)
|
35 | os.getcwdb(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
full_name.py:32:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
full_name.py:35:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
||||||
|
|
|
|
||||||
30 | fp.read()
|
33 | fp.read()
|
||||||
31 | open(p).close()
|
34 | open(p).close()
|
||||||
32 | os.getcwdb(p)
|
35 | os.getcwdb(p)
|
||||||
| ^^^^^^^^^^ PTH109
|
| ^^^^^^^^^^ PTH109
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,229 +1,249 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
||||||
---
|
---
|
||||||
import_as.py:6:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
import_as.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||||
|
|
|
|
||||||
4 | p = "/foo"
|
5 | q = "bar"
|
||||||
5 |
|
6 |
|
||||||
6 | a = foo_p.abspath(p)
|
7 | a = foo_p.abspath(p)
|
||||||
| ^^^^^^^^^^^^^ PTH100
|
| ^^^^^^^^^^^^^ PTH100
|
||||||
7 | aa = foo.chmod(p)
|
8 | aa = foo.chmod(p)
|
||||||
8 | aaa = foo.mkdir(p)
|
9 | aaa = foo.mkdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:7:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
import_as.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
||||||
|
|
|
|
||||||
6 | a = foo_p.abspath(p)
|
7 | a = foo_p.abspath(p)
|
||||||
7 | aa = foo.chmod(p)
|
8 | aa = foo.chmod(p)
|
||||||
| ^^^^^^^^^ PTH101
|
| ^^^^^^^^^ PTH101
|
||||||
8 | aaa = foo.mkdir(p)
|
9 | aaa = foo.mkdir(p)
|
||||||
9 | foo.makedirs(p)
|
10 | foo.makedirs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:8:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
import_as.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
||||||
|
|
|
|
||||||
6 | a = foo_p.abspath(p)
|
7 | a = foo_p.abspath(p)
|
||||||
7 | aa = foo.chmod(p)
|
8 | aa = foo.chmod(p)
|
||||||
8 | aaa = foo.mkdir(p)
|
9 | aaa = foo.mkdir(p)
|
||||||
| ^^^^^^^^^ PTH102
|
| ^^^^^^^^^ PTH102
|
||||||
9 | foo.makedirs(p)
|
10 | foo.makedirs(p)
|
||||||
10 | foo.rename(p)
|
11 | foo.rename(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:9:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
import_as.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
||||||
|
|
|
|
||||||
7 | aa = foo.chmod(p)
|
8 | aa = foo.chmod(p)
|
||||||
8 | aaa = foo.mkdir(p)
|
9 | aaa = foo.mkdir(p)
|
||||||
9 | foo.makedirs(p)
|
10 | foo.makedirs(p)
|
||||||
| ^^^^^^^^^^^^ PTH103
|
| ^^^^^^^^^^^^ PTH103
|
||||||
10 | foo.rename(p)
|
11 | foo.rename(p)
|
||||||
11 | foo.replace(p)
|
12 | foo.replace(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:10:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
import_as.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
||||||
|
|
|
|
||||||
8 | aaa = foo.mkdir(p)
|
9 | aaa = foo.mkdir(p)
|
||||||
9 | foo.makedirs(p)
|
10 | foo.makedirs(p)
|
||||||
10 | foo.rename(p)
|
11 | foo.rename(p)
|
||||||
| ^^^^^^^^^^ PTH104
|
| ^^^^^^^^^^ PTH104
|
||||||
11 | foo.replace(p)
|
12 | foo.replace(p)
|
||||||
12 | foo.rmdir(p)
|
13 | foo.rmdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:11:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
import_as.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
||||||
|
|
|
|
||||||
9 | foo.makedirs(p)
|
10 | foo.makedirs(p)
|
||||||
10 | foo.rename(p)
|
11 | foo.rename(p)
|
||||||
11 | foo.replace(p)
|
12 | foo.replace(p)
|
||||||
| ^^^^^^^^^^^ PTH105
|
| ^^^^^^^^^^^ PTH105
|
||||||
12 | foo.rmdir(p)
|
13 | foo.rmdir(p)
|
||||||
13 | foo.remove(p)
|
14 | foo.remove(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:12:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
import_as.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
||||||
|
|
|
|
||||||
10 | foo.rename(p)
|
11 | foo.rename(p)
|
||||||
11 | foo.replace(p)
|
12 | foo.replace(p)
|
||||||
12 | foo.rmdir(p)
|
13 | foo.rmdir(p)
|
||||||
| ^^^^^^^^^ PTH106
|
| ^^^^^^^^^ PTH106
|
||||||
13 | foo.remove(p)
|
14 | foo.remove(p)
|
||||||
14 | foo.unlink(p)
|
15 | foo.unlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:13:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
import_as.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
11 | foo.replace(p)
|
12 | foo.replace(p)
|
||||||
12 | foo.rmdir(p)
|
13 | foo.rmdir(p)
|
||||||
13 | foo.remove(p)
|
14 | foo.remove(p)
|
||||||
| ^^^^^^^^^^ PTH107
|
| ^^^^^^^^^^ PTH107
|
||||||
14 | foo.unlink(p)
|
15 | foo.unlink(p)
|
||||||
15 | foo.getcwd(p)
|
16 | foo.getcwd(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:14:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
import_as.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
12 | foo.rmdir(p)
|
13 | foo.rmdir(p)
|
||||||
13 | foo.remove(p)
|
14 | foo.remove(p)
|
||||||
14 | foo.unlink(p)
|
15 | foo.unlink(p)
|
||||||
| ^^^^^^^^^^ PTH108
|
| ^^^^^^^^^^ PTH108
|
||||||
15 | foo.getcwd(p)
|
16 | foo.getcwd(p)
|
||||||
16 | b = foo_p.exists(p)
|
17 | b = foo_p.exists(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:15:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
import_as.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
||||||
|
|
|
|
||||||
13 | foo.remove(p)
|
14 | foo.remove(p)
|
||||||
14 | foo.unlink(p)
|
15 | foo.unlink(p)
|
||||||
15 | foo.getcwd(p)
|
16 | foo.getcwd(p)
|
||||||
| ^^^^^^^^^^ PTH109
|
| ^^^^^^^^^^ PTH109
|
||||||
16 | b = foo_p.exists(p)
|
17 | b = foo_p.exists(p)
|
||||||
17 | bb = foo_p.expanduser(p)
|
18 | bb = foo_p.expanduser(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:16:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
import_as.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
||||||
|
|
|
|
||||||
14 | foo.unlink(p)
|
15 | foo.unlink(p)
|
||||||
15 | foo.getcwd(p)
|
16 | foo.getcwd(p)
|
||||||
16 | b = foo_p.exists(p)
|
17 | b = foo_p.exists(p)
|
||||||
| ^^^^^^^^^^^^ PTH110
|
| ^^^^^^^^^^^^ PTH110
|
||||||
17 | bb = foo_p.expanduser(p)
|
18 | bb = foo_p.expanduser(p)
|
||||||
18 | bbb = foo_p.isdir(p)
|
19 | bbb = foo_p.isdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:17:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
import_as.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
||||||
|
|
|
|
||||||
15 | foo.getcwd(p)
|
16 | foo.getcwd(p)
|
||||||
16 | b = foo_p.exists(p)
|
17 | b = foo_p.exists(p)
|
||||||
17 | bb = foo_p.expanduser(p)
|
18 | bb = foo_p.expanduser(p)
|
||||||
| ^^^^^^^^^^^^^^^^ PTH111
|
| ^^^^^^^^^^^^^^^^ PTH111
|
||||||
18 | bbb = foo_p.isdir(p)
|
19 | bbb = foo_p.isdir(p)
|
||||||
19 | bbbb = foo_p.isfile(p)
|
20 | bbbb = foo_p.isfile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:18:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
import_as.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
||||||
|
|
|
|
||||||
16 | b = foo_p.exists(p)
|
17 | b = foo_p.exists(p)
|
||||||
17 | bb = foo_p.expanduser(p)
|
18 | bb = foo_p.expanduser(p)
|
||||||
18 | bbb = foo_p.isdir(p)
|
19 | bbb = foo_p.isdir(p)
|
||||||
| ^^^^^^^^^^^ PTH112
|
| ^^^^^^^^^^^ PTH112
|
||||||
19 | bbbb = foo_p.isfile(p)
|
20 | bbbb = foo_p.isfile(p)
|
||||||
20 | bbbbb = foo_p.islink(p)
|
21 | bbbbb = foo_p.islink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:19:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
import_as.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||||
|
|
|
|
||||||
17 | bb = foo_p.expanduser(p)
|
18 | bb = foo_p.expanduser(p)
|
||||||
18 | bbb = foo_p.isdir(p)
|
19 | bbb = foo_p.isdir(p)
|
||||||
19 | bbbb = foo_p.isfile(p)
|
20 | bbbb = foo_p.isfile(p)
|
||||||
| ^^^^^^^^^^^^ PTH113
|
| ^^^^^^^^^^^^ PTH113
|
||||||
20 | bbbbb = foo_p.islink(p)
|
21 | bbbbb = foo_p.islink(p)
|
||||||
21 | foo.readlink(p)
|
22 | foo.readlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:20:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
import_as.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
||||||
|
|
|
|
||||||
18 | bbb = foo_p.isdir(p)
|
19 | bbb = foo_p.isdir(p)
|
||||||
19 | bbbb = foo_p.isfile(p)
|
20 | bbbb = foo_p.isfile(p)
|
||||||
20 | bbbbb = foo_p.islink(p)
|
21 | bbbbb = foo_p.islink(p)
|
||||||
| ^^^^^^^^^^^^ PTH114
|
| ^^^^^^^^^^^^ PTH114
|
||||||
21 | foo.readlink(p)
|
22 | foo.readlink(p)
|
||||||
22 | foo.stat(p)
|
23 | foo.stat(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:21:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
import_as.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
||||||
|
|
|
|
||||||
19 | bbbb = foo_p.isfile(p)
|
20 | bbbb = foo_p.isfile(p)
|
||||||
20 | bbbbb = foo_p.islink(p)
|
21 | bbbbb = foo_p.islink(p)
|
||||||
21 | foo.readlink(p)
|
22 | foo.readlink(p)
|
||||||
| ^^^^^^^^^^^^ PTH115
|
| ^^^^^^^^^^^^ PTH115
|
||||||
22 | foo.stat(p)
|
23 | foo.stat(p)
|
||||||
23 | foo_p.isabs(p)
|
24 | foo_p.isabs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:22:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
import_as.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
||||||
|
|
|
|
||||||
20 | bbbbb = foo_p.islink(p)
|
21 | bbbbb = foo_p.islink(p)
|
||||||
21 | foo.readlink(p)
|
22 | foo.readlink(p)
|
||||||
22 | foo.stat(p)
|
23 | foo.stat(p)
|
||||||
| ^^^^^^^^ PTH116
|
| ^^^^^^^^ PTH116
|
||||||
23 | foo_p.isabs(p)
|
24 | foo_p.isabs(p)
|
||||||
24 | foo_p.join(p)
|
25 | foo_p.join(p, q)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:23:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
import_as.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
||||||
|
|
|
|
||||||
21 | foo.readlink(p)
|
22 | foo.readlink(p)
|
||||||
22 | foo.stat(p)
|
23 | foo.stat(p)
|
||||||
23 | foo_p.isabs(p)
|
24 | foo_p.isabs(p)
|
||||||
| ^^^^^^^^^^^ PTH117
|
| ^^^^^^^^^^^ PTH117
|
||||||
24 | foo_p.join(p)
|
25 | foo_p.join(p, q)
|
||||||
25 | foo_p.basename(p)
|
26 | foo.sep.join([p, q])
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:24:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
import_as.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
22 | foo.stat(p)
|
23 | foo.stat(p)
|
||||||
23 | foo_p.isabs(p)
|
24 | foo_p.isabs(p)
|
||||||
24 | foo_p.join(p)
|
25 | foo_p.join(p, q)
|
||||||
| ^^^^^^^^^^ PTH118
|
| ^^^^^^^^^^ PTH118
|
||||||
25 | foo_p.basename(p)
|
26 | foo.sep.join([p, q])
|
||||||
26 | foo_p.dirname(p)
|
27 | foo.sep.join((p, q))
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:25:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
import_as.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
23 | foo_p.isabs(p)
|
24 | foo_p.isabs(p)
|
||||||
24 | foo_p.join(p)
|
25 | foo_p.join(p, q)
|
||||||
25 | foo_p.basename(p)
|
26 | foo.sep.join([p, q])
|
||||||
|
| ^^^^^^^^^^^^ PTH118
|
||||||
|
27 | foo.sep.join((p, q))
|
||||||
|
28 | foo_p.basename(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_as.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
||||||
|
25 | foo_p.join(p, q)
|
||||||
|
26 | foo.sep.join([p, q])
|
||||||
|
27 | foo.sep.join((p, q))
|
||||||
|
| ^^^^^^^^^^^^ PTH118
|
||||||
|
28 | foo_p.basename(p)
|
||||||
|
29 | foo_p.dirname(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_as.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
||||||
|
|
|
||||||
|
26 | foo.sep.join([p, q])
|
||||||
|
27 | foo.sep.join((p, q))
|
||||||
|
28 | foo_p.basename(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH119
|
| ^^^^^^^^^^^^^^ PTH119
|
||||||
26 | foo_p.dirname(p)
|
29 | foo_p.dirname(p)
|
||||||
27 | foo_p.samefile(p)
|
30 | foo_p.samefile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:26:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
import_as.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
||||||
|
|
|
|
||||||
24 | foo_p.join(p)
|
27 | foo.sep.join((p, q))
|
||||||
25 | foo_p.basename(p)
|
28 | foo_p.basename(p)
|
||||||
26 | foo_p.dirname(p)
|
29 | foo_p.dirname(p)
|
||||||
| ^^^^^^^^^^^^^ PTH120
|
| ^^^^^^^^^^^^^ PTH120
|
||||||
27 | foo_p.samefile(p)
|
30 | foo_p.samefile(p)
|
||||||
28 | foo_p.splitext(p)
|
31 | foo_p.splitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:27:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
import_as.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
||||||
|
|
|
|
||||||
25 | foo_p.basename(p)
|
28 | foo_p.basename(p)
|
||||||
26 | foo_p.dirname(p)
|
29 | foo_p.dirname(p)
|
||||||
27 | foo_p.samefile(p)
|
30 | foo_p.samefile(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH121
|
| ^^^^^^^^^^^^^^ PTH121
|
||||||
28 | foo_p.splitext(p)
|
31 | foo_p.splitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_as.py:28:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
import_as.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
||||||
|
|
|
|
||||||
26 | foo_p.dirname(p)
|
29 | foo_p.dirname(p)
|
||||||
27 | foo_p.samefile(p)
|
30 | foo_p.samefile(p)
|
||||||
28 | foo_p.splitext(p)
|
31 | foo_p.splitext(p)
|
||||||
| ^^^^^^^^^^^^^^ PTH122
|
| ^^^^^^^^^^^^^^ PTH122
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,250 +1,270 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
||||||
---
|
---
|
||||||
import_from.py:8:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
import_from.py:9:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||||
|
|
|
|
||||||
6 | p = "/foo"
|
7 | q = "bar"
|
||||||
7 |
|
8 |
|
||||||
8 | a = abspath(p)
|
9 | a = abspath(p)
|
||||||
| ^^^^^^^ PTH100
|
| ^^^^^^^ PTH100
|
||||||
9 | aa = chmod(p)
|
10 | aa = chmod(p)
|
||||||
10 | aaa = mkdir(p)
|
11 | aaa = mkdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:9:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
import_from.py:10:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
||||||
|
|
|
|
||||||
8 | a = abspath(p)
|
9 | a = abspath(p)
|
||||||
9 | aa = chmod(p)
|
10 | aa = chmod(p)
|
||||||
| ^^^^^ PTH101
|
| ^^^^^ PTH101
|
||||||
10 | aaa = mkdir(p)
|
11 | aaa = mkdir(p)
|
||||||
11 | makedirs(p)
|
12 | makedirs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:10:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
import_from.py:11:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
||||||
|
|
|
|
||||||
8 | a = abspath(p)
|
9 | a = abspath(p)
|
||||||
9 | aa = chmod(p)
|
10 | aa = chmod(p)
|
||||||
10 | aaa = mkdir(p)
|
11 | aaa = mkdir(p)
|
||||||
| ^^^^^ PTH102
|
| ^^^^^ PTH102
|
||||||
11 | makedirs(p)
|
12 | makedirs(p)
|
||||||
12 | rename(p)
|
13 | rename(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:11:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
import_from.py:12:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
||||||
|
|
|
|
||||||
9 | aa = chmod(p)
|
10 | aa = chmod(p)
|
||||||
10 | aaa = mkdir(p)
|
11 | aaa = mkdir(p)
|
||||||
11 | makedirs(p)
|
12 | makedirs(p)
|
||||||
| ^^^^^^^^ PTH103
|
| ^^^^^^^^ PTH103
|
||||||
12 | rename(p)
|
13 | rename(p)
|
||||||
13 | replace(p)
|
14 | replace(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:12:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
import_from.py:13:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
||||||
|
|
|
|
||||||
10 | aaa = mkdir(p)
|
11 | aaa = mkdir(p)
|
||||||
11 | makedirs(p)
|
12 | makedirs(p)
|
||||||
12 | rename(p)
|
13 | rename(p)
|
||||||
| ^^^^^^ PTH104
|
| ^^^^^^ PTH104
|
||||||
13 | replace(p)
|
14 | replace(p)
|
||||||
14 | rmdir(p)
|
15 | rmdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:13:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
import_from.py:14:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
||||||
|
|
|
|
||||||
11 | makedirs(p)
|
12 | makedirs(p)
|
||||||
12 | rename(p)
|
13 | rename(p)
|
||||||
13 | replace(p)
|
14 | replace(p)
|
||||||
| ^^^^^^^ PTH105
|
| ^^^^^^^ PTH105
|
||||||
14 | rmdir(p)
|
15 | rmdir(p)
|
||||||
15 | remove(p)
|
16 | remove(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:14:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
import_from.py:15:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
||||||
|
|
|
|
||||||
12 | rename(p)
|
13 | rename(p)
|
||||||
13 | replace(p)
|
14 | replace(p)
|
||||||
14 | rmdir(p)
|
15 | rmdir(p)
|
||||||
| ^^^^^ PTH106
|
| ^^^^^ PTH106
|
||||||
15 | remove(p)
|
16 | remove(p)
|
||||||
16 | unlink(p)
|
17 | unlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:15:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
import_from.py:16:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
13 | replace(p)
|
14 | replace(p)
|
||||||
14 | rmdir(p)
|
15 | rmdir(p)
|
||||||
15 | remove(p)
|
16 | remove(p)
|
||||||
| ^^^^^^ PTH107
|
| ^^^^^^ PTH107
|
||||||
16 | unlink(p)
|
17 | unlink(p)
|
||||||
17 | getcwd(p)
|
18 | getcwd(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:16:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
import_from.py:17:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
14 | rmdir(p)
|
15 | rmdir(p)
|
||||||
15 | remove(p)
|
16 | remove(p)
|
||||||
16 | unlink(p)
|
17 | unlink(p)
|
||||||
| ^^^^^^ PTH108
|
| ^^^^^^ PTH108
|
||||||
17 | getcwd(p)
|
18 | getcwd(p)
|
||||||
18 | b = exists(p)
|
19 | b = exists(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:17:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
import_from.py:18:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
||||||
|
|
|
|
||||||
15 | remove(p)
|
16 | remove(p)
|
||||||
16 | unlink(p)
|
17 | unlink(p)
|
||||||
17 | getcwd(p)
|
18 | getcwd(p)
|
||||||
| ^^^^^^ PTH109
|
| ^^^^^^ PTH109
|
||||||
18 | b = exists(p)
|
19 | b = exists(p)
|
||||||
19 | bb = expanduser(p)
|
20 | bb = expanduser(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:18:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
import_from.py:19:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
||||||
|
|
|
|
||||||
16 | unlink(p)
|
17 | unlink(p)
|
||||||
17 | getcwd(p)
|
18 | getcwd(p)
|
||||||
18 | b = exists(p)
|
19 | b = exists(p)
|
||||||
| ^^^^^^ PTH110
|
| ^^^^^^ PTH110
|
||||||
19 | bb = expanduser(p)
|
20 | bb = expanduser(p)
|
||||||
20 | bbb = isdir(p)
|
21 | bbb = isdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:19:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
import_from.py:20:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
||||||
|
|
|
|
||||||
17 | getcwd(p)
|
18 | getcwd(p)
|
||||||
18 | b = exists(p)
|
19 | b = exists(p)
|
||||||
19 | bb = expanduser(p)
|
20 | bb = expanduser(p)
|
||||||
| ^^^^^^^^^^ PTH111
|
| ^^^^^^^^^^ PTH111
|
||||||
20 | bbb = isdir(p)
|
21 | bbb = isdir(p)
|
||||||
21 | bbbb = isfile(p)
|
22 | bbbb = isfile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:20:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
import_from.py:21:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
||||||
|
|
|
|
||||||
18 | b = exists(p)
|
19 | b = exists(p)
|
||||||
19 | bb = expanduser(p)
|
20 | bb = expanduser(p)
|
||||||
20 | bbb = isdir(p)
|
21 | bbb = isdir(p)
|
||||||
| ^^^^^ PTH112
|
| ^^^^^ PTH112
|
||||||
21 | bbbb = isfile(p)
|
22 | bbbb = isfile(p)
|
||||||
22 | bbbbb = islink(p)
|
23 | bbbbb = islink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:21:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
import_from.py:22:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||||
|
|
|
|
||||||
19 | bb = expanduser(p)
|
20 | bb = expanduser(p)
|
||||||
20 | bbb = isdir(p)
|
21 | bbb = isdir(p)
|
||||||
21 | bbbb = isfile(p)
|
22 | bbbb = isfile(p)
|
||||||
| ^^^^^^ PTH113
|
| ^^^^^^ PTH113
|
||||||
22 | bbbbb = islink(p)
|
23 | bbbbb = islink(p)
|
||||||
23 | readlink(p)
|
24 | readlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:22:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
import_from.py:23:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
||||||
|
|
|
|
||||||
20 | bbb = isdir(p)
|
21 | bbb = isdir(p)
|
||||||
21 | bbbb = isfile(p)
|
22 | bbbb = isfile(p)
|
||||||
22 | bbbbb = islink(p)
|
23 | bbbbb = islink(p)
|
||||||
| ^^^^^^ PTH114
|
| ^^^^^^ PTH114
|
||||||
23 | readlink(p)
|
24 | readlink(p)
|
||||||
24 | stat(p)
|
25 | stat(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:23:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
import_from.py:24:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
||||||
|
|
|
|
||||||
21 | bbbb = isfile(p)
|
22 | bbbb = isfile(p)
|
||||||
22 | bbbbb = islink(p)
|
23 | bbbbb = islink(p)
|
||||||
23 | readlink(p)
|
24 | readlink(p)
|
||||||
| ^^^^^^^^ PTH115
|
| ^^^^^^^^ PTH115
|
||||||
24 | stat(p)
|
25 | stat(p)
|
||||||
25 | isabs(p)
|
26 | isabs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:24:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
import_from.py:25:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
||||||
|
|
|
|
||||||
22 | bbbbb = islink(p)
|
23 | bbbbb = islink(p)
|
||||||
23 | readlink(p)
|
24 | readlink(p)
|
||||||
24 | stat(p)
|
25 | stat(p)
|
||||||
| ^^^^ PTH116
|
| ^^^^ PTH116
|
||||||
25 | isabs(p)
|
26 | isabs(p)
|
||||||
26 | join(p)
|
27 | join(p, q)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:25:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
import_from.py:26:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
||||||
|
|
|
|
||||||
23 | readlink(p)
|
24 | readlink(p)
|
||||||
24 | stat(p)
|
25 | stat(p)
|
||||||
25 | isabs(p)
|
26 | isabs(p)
|
||||||
| ^^^^^ PTH117
|
| ^^^^^ PTH117
|
||||||
26 | join(p)
|
27 | join(p, q)
|
||||||
27 | basename(p)
|
28 | sep.join((p, q))
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:26:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
import_from.py:27:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
24 | stat(p)
|
25 | stat(p)
|
||||||
25 | isabs(p)
|
26 | isabs(p)
|
||||||
26 | join(p)
|
27 | join(p, q)
|
||||||
| ^^^^ PTH118
|
| ^^^^ PTH118
|
||||||
27 | basename(p)
|
28 | sep.join((p, q))
|
||||||
28 | dirname(p)
|
29 | sep.join([p, q])
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:27:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
import_from.py:28:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
25 | isabs(p)
|
26 | isabs(p)
|
||||||
26 | join(p)
|
27 | join(p, q)
|
||||||
27 | basename(p)
|
28 | sep.join((p, q))
|
||||||
|
| ^^^^^^^^ PTH118
|
||||||
|
29 | sep.join([p, q])
|
||||||
|
30 | basename(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_from.py:29:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
||||||
|
27 | join(p, q)
|
||||||
|
28 | sep.join((p, q))
|
||||||
|
29 | sep.join([p, q])
|
||||||
|
| ^^^^^^^^ PTH118
|
||||||
|
30 | basename(p)
|
||||||
|
31 | dirname(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_from.py:30:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
||||||
|
|
|
||||||
|
28 | sep.join((p, q))
|
||||||
|
29 | sep.join([p, q])
|
||||||
|
30 | basename(p)
|
||||||
| ^^^^^^^^ PTH119
|
| ^^^^^^^^ PTH119
|
||||||
28 | dirname(p)
|
31 | dirname(p)
|
||||||
29 | samefile(p)
|
32 | samefile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:28:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
import_from.py:31:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
||||||
|
|
|
|
||||||
26 | join(p)
|
29 | sep.join([p, q])
|
||||||
27 | basename(p)
|
30 | basename(p)
|
||||||
28 | dirname(p)
|
31 | dirname(p)
|
||||||
| ^^^^^^^ PTH120
|
| ^^^^^^^ PTH120
|
||||||
29 | samefile(p)
|
32 | samefile(p)
|
||||||
30 | splitext(p)
|
33 | splitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:29:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
import_from.py:32:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
||||||
|
|
|
|
||||||
27 | basename(p)
|
30 | basename(p)
|
||||||
28 | dirname(p)
|
31 | dirname(p)
|
||||||
29 | samefile(p)
|
32 | samefile(p)
|
||||||
| ^^^^^^^^ PTH121
|
| ^^^^^^^^ PTH121
|
||||||
30 | splitext(p)
|
33 | splitext(p)
|
||||||
31 | with open(p) as fp:
|
34 | with open(p) as fp:
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:30:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
import_from.py:33:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
||||||
|
|
|
|
||||||
28 | dirname(p)
|
31 | dirname(p)
|
||||||
29 | samefile(p)
|
32 | samefile(p)
|
||||||
30 | splitext(p)
|
33 | splitext(p)
|
||||||
| ^^^^^^^^ PTH122
|
| ^^^^^^^^ PTH122
|
||||||
31 | with open(p) as fp:
|
34 | with open(p) as fp:
|
||||||
32 | fp.read()
|
35 | fp.read()
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:31:6: PTH123 `open()` should be replaced by `Path.open()`
|
import_from.py:34:6: PTH123 `open()` should be replaced by `Path.open()`
|
||||||
|
|
|
|
||||||
29 | samefile(p)
|
32 | samefile(p)
|
||||||
30 | splitext(p)
|
33 | splitext(p)
|
||||||
31 | with open(p) as fp:
|
34 | with open(p) as fp:
|
||||||
| ^^^^ PTH123
|
| ^^^^ PTH123
|
||||||
32 | fp.read()
|
35 | fp.read()
|
||||||
33 | open(p).close()
|
36 | open(p).close()
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from.py:33:1: PTH123 `open()` should be replaced by `Path.open()`
|
import_from.py:36:1: PTH123 `open()` should be replaced by `Path.open()`
|
||||||
|
|
|
|
||||||
31 | with open(p) as fp:
|
34 | with open(p) as fp:
|
||||||
32 | fp.read()
|
35 | fp.read()
|
||||||
33 | open(p).close()
|
36 | open(p).close()
|
||||||
| ^^^^ PTH123
|
| ^^^^ PTH123
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,229 +1,249 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs
|
||||||
---
|
---
|
||||||
import_from_as.py:13:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
import_from_as.py:14:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||||
|
|
|
|
||||||
11 | p = "/foo"
|
12 | q = "bar"
|
||||||
12 |
|
13 |
|
||||||
13 | a = xabspath(p)
|
14 | a = xabspath(p)
|
||||||
| ^^^^^^^^ PTH100
|
| ^^^^^^^^ PTH100
|
||||||
14 | aa = xchmod(p)
|
15 | aa = xchmod(p)
|
||||||
15 | aaa = xmkdir(p)
|
16 | aaa = xmkdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:14:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
import_from_as.py:15:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()`
|
||||||
|
|
|
|
||||||
13 | a = xabspath(p)
|
14 | a = xabspath(p)
|
||||||
14 | aa = xchmod(p)
|
15 | aa = xchmod(p)
|
||||||
| ^^^^^^ PTH101
|
| ^^^^^^ PTH101
|
||||||
15 | aaa = xmkdir(p)
|
16 | aaa = xmkdir(p)
|
||||||
16 | xmakedirs(p)
|
17 | xmakedirs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:15:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
import_from_as.py:16:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()`
|
||||||
|
|
|
|
||||||
13 | a = xabspath(p)
|
14 | a = xabspath(p)
|
||||||
14 | aa = xchmod(p)
|
15 | aa = xchmod(p)
|
||||||
15 | aaa = xmkdir(p)
|
16 | aaa = xmkdir(p)
|
||||||
| ^^^^^^ PTH102
|
| ^^^^^^ PTH102
|
||||||
16 | xmakedirs(p)
|
17 | xmakedirs(p)
|
||||||
17 | xrename(p)
|
18 | xrename(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:16:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
import_from_as.py:17:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
|
||||||
|
|
|
|
||||||
14 | aa = xchmod(p)
|
15 | aa = xchmod(p)
|
||||||
15 | aaa = xmkdir(p)
|
16 | aaa = xmkdir(p)
|
||||||
16 | xmakedirs(p)
|
17 | xmakedirs(p)
|
||||||
| ^^^^^^^^^ PTH103
|
| ^^^^^^^^^ PTH103
|
||||||
17 | xrename(p)
|
18 | xrename(p)
|
||||||
18 | xreplace(p)
|
19 | xreplace(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:17:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
import_from_as.py:18:1: PTH104 `os.rename()` should be replaced by `Path.rename()`
|
||||||
|
|
|
|
||||||
15 | aaa = xmkdir(p)
|
16 | aaa = xmkdir(p)
|
||||||
16 | xmakedirs(p)
|
17 | xmakedirs(p)
|
||||||
17 | xrename(p)
|
18 | xrename(p)
|
||||||
| ^^^^^^^ PTH104
|
| ^^^^^^^ PTH104
|
||||||
18 | xreplace(p)
|
19 | xreplace(p)
|
||||||
19 | xrmdir(p)
|
20 | xrmdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:18:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
import_from_as.py:19:1: PTH105 `os.replace()` should be replaced by `Path.replace()`
|
||||||
|
|
|
|
||||||
16 | xmakedirs(p)
|
17 | xmakedirs(p)
|
||||||
17 | xrename(p)
|
18 | xrename(p)
|
||||||
18 | xreplace(p)
|
19 | xreplace(p)
|
||||||
| ^^^^^^^^ PTH105
|
| ^^^^^^^^ PTH105
|
||||||
19 | xrmdir(p)
|
20 | xrmdir(p)
|
||||||
20 | xremove(p)
|
21 | xremove(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:19:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
import_from_as.py:20:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()`
|
||||||
|
|
|
|
||||||
17 | xrename(p)
|
18 | xrename(p)
|
||||||
18 | xreplace(p)
|
19 | xreplace(p)
|
||||||
19 | xrmdir(p)
|
20 | xrmdir(p)
|
||||||
| ^^^^^^ PTH106
|
| ^^^^^^ PTH106
|
||||||
20 | xremove(p)
|
21 | xremove(p)
|
||||||
21 | xunlink(p)
|
22 | xunlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:20:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
import_from_as.py:21:1: PTH107 `os.remove()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
18 | xreplace(p)
|
19 | xreplace(p)
|
||||||
19 | xrmdir(p)
|
20 | xrmdir(p)
|
||||||
20 | xremove(p)
|
21 | xremove(p)
|
||||||
| ^^^^^^^ PTH107
|
| ^^^^^^^ PTH107
|
||||||
21 | xunlink(p)
|
22 | xunlink(p)
|
||||||
22 | xgetcwd(p)
|
23 | xgetcwd(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:21:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
import_from_as.py:22:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()`
|
||||||
|
|
|
|
||||||
19 | xrmdir(p)
|
20 | xrmdir(p)
|
||||||
20 | xremove(p)
|
21 | xremove(p)
|
||||||
21 | xunlink(p)
|
22 | xunlink(p)
|
||||||
| ^^^^^^^ PTH108
|
| ^^^^^^^ PTH108
|
||||||
22 | xgetcwd(p)
|
23 | xgetcwd(p)
|
||||||
23 | b = xexists(p)
|
24 | b = xexists(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:22:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
import_from_as.py:23:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
|
||||||
|
|
|
|
||||||
20 | xremove(p)
|
21 | xremove(p)
|
||||||
21 | xunlink(p)
|
22 | xunlink(p)
|
||||||
22 | xgetcwd(p)
|
23 | xgetcwd(p)
|
||||||
| ^^^^^^^ PTH109
|
| ^^^^^^^ PTH109
|
||||||
23 | b = xexists(p)
|
24 | b = xexists(p)
|
||||||
24 | bb = xexpanduser(p)
|
25 | bb = xexpanduser(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:23:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
import_from_as.py:24:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
|
||||||
|
|
|
|
||||||
21 | xunlink(p)
|
22 | xunlink(p)
|
||||||
22 | xgetcwd(p)
|
23 | xgetcwd(p)
|
||||||
23 | b = xexists(p)
|
24 | b = xexists(p)
|
||||||
| ^^^^^^^ PTH110
|
| ^^^^^^^ PTH110
|
||||||
24 | bb = xexpanduser(p)
|
25 | bb = xexpanduser(p)
|
||||||
25 | bbb = xisdir(p)
|
26 | bbb = xisdir(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:24:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
import_from_as.py:25:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
|
||||||
|
|
|
|
||||||
22 | xgetcwd(p)
|
23 | xgetcwd(p)
|
||||||
23 | b = xexists(p)
|
24 | b = xexists(p)
|
||||||
24 | bb = xexpanduser(p)
|
25 | bb = xexpanduser(p)
|
||||||
| ^^^^^^^^^^^ PTH111
|
| ^^^^^^^^^^^ PTH111
|
||||||
25 | bbb = xisdir(p)
|
26 | bbb = xisdir(p)
|
||||||
26 | bbbb = xisfile(p)
|
27 | bbbb = xisfile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:25:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
import_from_as.py:26:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
|
||||||
|
|
|
|
||||||
23 | b = xexists(p)
|
24 | b = xexists(p)
|
||||||
24 | bb = xexpanduser(p)
|
25 | bb = xexpanduser(p)
|
||||||
25 | bbb = xisdir(p)
|
26 | bbb = xisdir(p)
|
||||||
| ^^^^^^ PTH112
|
| ^^^^^^ PTH112
|
||||||
26 | bbbb = xisfile(p)
|
27 | bbbb = xisfile(p)
|
||||||
27 | bbbbb = xislink(p)
|
28 | bbbbb = xislink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:26:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
import_from_as.py:27:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||||
|
|
|
|
||||||
24 | bb = xexpanduser(p)
|
25 | bb = xexpanduser(p)
|
||||||
25 | bbb = xisdir(p)
|
26 | bbb = xisdir(p)
|
||||||
26 | bbbb = xisfile(p)
|
27 | bbbb = xisfile(p)
|
||||||
| ^^^^^^^ PTH113
|
| ^^^^^^^ PTH113
|
||||||
27 | bbbbb = xislink(p)
|
28 | bbbbb = xislink(p)
|
||||||
28 | xreadlink(p)
|
29 | xreadlink(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:27:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
import_from_as.py:28:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()`
|
||||||
|
|
|
|
||||||
25 | bbb = xisdir(p)
|
26 | bbb = xisdir(p)
|
||||||
26 | bbbb = xisfile(p)
|
27 | bbbb = xisfile(p)
|
||||||
27 | bbbbb = xislink(p)
|
28 | bbbbb = xislink(p)
|
||||||
| ^^^^^^^ PTH114
|
| ^^^^^^^ PTH114
|
||||||
28 | xreadlink(p)
|
29 | xreadlink(p)
|
||||||
29 | xstat(p)
|
30 | xstat(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:28:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
import_from_as.py:29:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()`
|
||||||
|
|
|
|
||||||
26 | bbbb = xisfile(p)
|
27 | bbbb = xisfile(p)
|
||||||
27 | bbbbb = xislink(p)
|
28 | bbbbb = xislink(p)
|
||||||
28 | xreadlink(p)
|
29 | xreadlink(p)
|
||||||
| ^^^^^^^^^ PTH115
|
| ^^^^^^^^^ PTH115
|
||||||
29 | xstat(p)
|
30 | xstat(p)
|
||||||
30 | xisabs(p)
|
31 | xisabs(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:29:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
import_from_as.py:30:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
|
||||||
|
|
|
|
||||||
27 | bbbbb = xislink(p)
|
28 | bbbbb = xislink(p)
|
||||||
28 | xreadlink(p)
|
29 | xreadlink(p)
|
||||||
29 | xstat(p)
|
30 | xstat(p)
|
||||||
| ^^^^^ PTH116
|
| ^^^^^ PTH116
|
||||||
30 | xisabs(p)
|
31 | xisabs(p)
|
||||||
31 | xjoin(p)
|
32 | xjoin(p, q)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:30:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
import_from_as.py:31:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
|
||||||
|
|
|
|
||||||
28 | xreadlink(p)
|
29 | xreadlink(p)
|
||||||
29 | xstat(p)
|
30 | xstat(p)
|
||||||
30 | xisabs(p)
|
31 | xisabs(p)
|
||||||
| ^^^^^^ PTH117
|
| ^^^^^^ PTH117
|
||||||
31 | xjoin(p)
|
32 | xjoin(p, q)
|
||||||
32 | xbasename(p)
|
33 | s.join((p, q))
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:31:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
import_from_as.py:32:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
29 | xstat(p)
|
30 | xstat(p)
|
||||||
30 | xisabs(p)
|
31 | xisabs(p)
|
||||||
31 | xjoin(p)
|
32 | xjoin(p, q)
|
||||||
| ^^^^^ PTH118
|
| ^^^^^ PTH118
|
||||||
32 | xbasename(p)
|
33 | s.join((p, q))
|
||||||
33 | xdirname(p)
|
34 | s.join([p, q])
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:32:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
import_from_as.py:33:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
|
||||||
30 | xisabs(p)
|
31 | xisabs(p)
|
||||||
31 | xjoin(p)
|
32 | xjoin(p, q)
|
||||||
32 | xbasename(p)
|
33 | s.join((p, q))
|
||||||
|
| ^^^^^^ PTH118
|
||||||
|
34 | s.join([p, q])
|
||||||
|
35 | xbasename(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_from_as.py:34:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator
|
||||||
|
|
|
||||||
|
32 | xjoin(p, q)
|
||||||
|
33 | s.join((p, q))
|
||||||
|
34 | s.join([p, q])
|
||||||
|
| ^^^^^^ PTH118
|
||||||
|
35 | xbasename(p)
|
||||||
|
36 | xdirname(p)
|
||||||
|
|
|
||||||
|
|
||||||
|
import_from_as.py:35:1: PTH119 `os.path.basename()` should be replaced by `Path.name`
|
||||||
|
|
|
||||||
|
33 | s.join((p, q))
|
||||||
|
34 | s.join([p, q])
|
||||||
|
35 | xbasename(p)
|
||||||
| ^^^^^^^^^ PTH119
|
| ^^^^^^^^^ PTH119
|
||||||
33 | xdirname(p)
|
36 | xdirname(p)
|
||||||
34 | xsamefile(p)
|
37 | xsamefile(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:33:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
import_from_as.py:36:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent`
|
||||||
|
|
|
|
||||||
31 | xjoin(p)
|
34 | s.join([p, q])
|
||||||
32 | xbasename(p)
|
35 | xbasename(p)
|
||||||
33 | xdirname(p)
|
36 | xdirname(p)
|
||||||
| ^^^^^^^^ PTH120
|
| ^^^^^^^^ PTH120
|
||||||
34 | xsamefile(p)
|
37 | xsamefile(p)
|
||||||
35 | xsplitext(p)
|
38 | xsplitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:34:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
import_from_as.py:37:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()`
|
||||||
|
|
|
|
||||||
32 | xbasename(p)
|
35 | xbasename(p)
|
||||||
33 | xdirname(p)
|
36 | xdirname(p)
|
||||||
34 | xsamefile(p)
|
37 | xsamefile(p)
|
||||||
| ^^^^^^^^^ PTH121
|
| ^^^^^^^^^ PTH121
|
||||||
35 | xsplitext(p)
|
38 | xsplitext(p)
|
||||||
|
|
|
|
||||||
|
|
||||||
import_from_as.py:35:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
import_from_as.py:38:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`
|
||||||
|
|
|
|
||||||
33 | xdirname(p)
|
36 | xdirname(p)
|
||||||
34 | xsamefile(p)
|
37 | xsamefile(p)
|
||||||
35 | xsplitext(p)
|
38 | xsplitext(p)
|
||||||
| ^^^^^^^^^ PTH122
|
| ^^^^^^^^^ PTH122
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -827,12 +827,15 @@ impl Violation for OsPathIsabs {
|
||||||
/// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/)
|
/// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/)
|
||||||
/// - [No really, pathlib is great](https://treyhunner.com/2019/01/no-really-pathlib-is-great/)
|
/// - [No really, pathlib is great](https://treyhunner.com/2019/01/no-really-pathlib-is-great/)
|
||||||
#[violation]
|
#[violation]
|
||||||
pub struct OsPathJoin;
|
pub struct OsPathJoin {
|
||||||
|
pub module: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Violation for OsPathJoin {
|
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")
|
let OsPathJoin { module } = self;
|
||||||
|
format!("`os.{module}.join()` should be replaced by `Path` with `/` operator")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue