[pyupgrade]: Improve diagnostic range for redundant-open-mode (UP015) (#16672)
## Summary This PR stabilizes the behavior change introduced in https://github.com/astral-sh/ruff/pull/15872/ The diagnostic range is now the range of the redundant `mode` argument where it previously was the range of the entire `open` call: Before: ``` UP015.py:2:1: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^^^^^^^^^^^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` Now: ``` UP015.py:2:13: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` This is a breaking change because it may require moving a `noqa` comment onto a different line, e.g if you have ```py open( "foo", "Ur", ) # noqa: UP015 ``` Needs to be rewritten to ```py open( "foo", "Ur", # noqa: UP015 ) ``` There have been now new issues or PRs since the new preview behavior was implemented. It first was released as part of Ruff 0.9.5 on the 5th of Feb (a little more than a month ago) ## Test Plan I reviewed the snapshot tests
This commit is contained in:
@@ -119,25 +119,6 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::RedundantOpenModes, Path::new("UP015.py"))]
|
||||
#[test_case(Rule::RedundantOpenModes, Path::new("UP015_1.py"))]
|
||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!(
|
||||
"preview__{}_{}",
|
||||
rule_code.noqa_code(),
|
||||
path.to_string_lossy()
|
||||
);
|
||||
let diagnostics = test_path(
|
||||
Path::new("pyupgrade").join(path).as_path(),
|
||||
&settings::LinterSettings {
|
||||
preview: PreviewMode::Enabled,
|
||||
..settings::LinterSettings::for_rule(rule_code)
|
||||
},
|
||||
)?;
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn up007_preview() -> Result<()> {
|
||||
let diagnostics = test_path(
|
||||
|
||||
@@ -91,17 +91,11 @@ fn create_diagnostic(
|
||||
mode: OpenMode,
|
||||
checker: &Checker,
|
||||
) -> Diagnostic {
|
||||
let range = if checker.settings.preview.is_enabled() {
|
||||
mode_arg.range()
|
||||
} else {
|
||||
call.range
|
||||
};
|
||||
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
RedundantOpenModes {
|
||||
replacement: mode.to_string(),
|
||||
},
|
||||
range,
|
||||
mode_arg.range(),
|
||||
);
|
||||
|
||||
if mode.is_empty() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
|
||||
---
|
||||
UP015.py:1:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:1:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
|
|
||||
@@ -17,11 +17,11 @@ UP015.py:1:1: UP015 [*] Unnecessary mode argument
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
|
||||
UP015.py:2:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:2:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
2 | open("foo", "Ur")
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
|
|
||||
@@ -35,12 +35,12 @@ UP015.py:2:1: UP015 [*] Unnecessary mode argument
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
|
||||
UP015.py:3:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:3:13: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
|
|
||||
@@ -55,12 +55,12 @@ UP015.py:3:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
|
||||
UP015.py:4:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:4:13: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
| ^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^^ UP015
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
|
|
||||
@@ -76,12 +76,12 @@ UP015.py:4:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
|
||||
UP015.py:5:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:5:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
|
|
||||
@@ -97,12 +97,12 @@ UP015.py:5:1: UP015 [*] Unnecessary mode argument
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
|
||||
UP015.py:6:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:6:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
|
|
||||
@@ -118,12 +118,12 @@ UP015.py:6:1: UP015 [*] Unnecessary mode argument
|
||||
8 8 | open("f", "wt")
|
||||
9 9 | open("f", "tw")
|
||||
|
||||
UP015.py:7:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:7:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
8 | open("f", "wt")
|
||||
9 | open("f", "tw")
|
||||
|
|
||||
@@ -139,12 +139,12 @@ UP015.py:7:1: UP015 [*] Unnecessary mode argument
|
||||
9 9 | open("f", "tw")
|
||||
10 10 |
|
||||
|
||||
UP015.py:8:1: UP015 [*] Unnecessary modes, use `w`
|
||||
UP015.py:8:11: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
| ^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
9 | open("f", "tw")
|
||||
|
|
||||
= help: Replace with `w`
|
||||
@@ -159,12 +159,12 @@ UP015.py:8:1: UP015 [*] Unnecessary modes, use `w`
|
||||
10 10 |
|
||||
11 11 | with open("foo", "U") as f:
|
||||
|
||||
UP015.py:9:1: UP015 [*] Unnecessary modes, use `w`
|
||||
UP015.py:9:11: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
9 | open("f", "tw")
|
||||
| ^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
10 |
|
||||
11 | with open("foo", "U") as f:
|
||||
|
|
||||
@@ -180,12 +180,12 @@ UP015.py:9:1: UP015 [*] Unnecessary modes, use `w`
|
||||
11 11 | with open("foo", "U") as f:
|
||||
12 12 | pass
|
||||
|
||||
UP015.py:11:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:11:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
9 | open("f", "tw")
|
||||
10 |
|
||||
11 | with open("foo", "U") as f:
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
12 | pass
|
||||
13 | with open("foo", "Ur") as f:
|
||||
|
|
||||
@@ -201,12 +201,12 @@ UP015.py:11:6: UP015 [*] Unnecessary mode argument
|
||||
13 13 | with open("foo", "Ur") as f:
|
||||
14 14 | pass
|
||||
|
||||
UP015.py:13:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:13:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
11 | with open("foo", "U") as f:
|
||||
12 | pass
|
||||
13 | with open("foo", "Ur") as f:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
14 | pass
|
||||
15 | with open("foo", "Ub") as f:
|
||||
|
|
||||
@@ -222,12 +222,12 @@ UP015.py:13:6: UP015 [*] Unnecessary mode argument
|
||||
15 15 | with open("foo", "Ub") as f:
|
||||
16 16 | pass
|
||||
|
||||
UP015.py:15:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:15:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
13 | with open("foo", "Ur") as f:
|
||||
14 | pass
|
||||
15 | with open("foo", "Ub") as f:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
16 | pass
|
||||
17 | with open("foo", "rUb") as f:
|
||||
|
|
||||
@@ -243,12 +243,12 @@ UP015.py:15:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
17 17 | with open("foo", "rUb") as f:
|
||||
18 18 | pass
|
||||
|
||||
UP015.py:17:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:17:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
15 | with open("foo", "Ub") as f:
|
||||
16 | pass
|
||||
17 | with open("foo", "rUb") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^^ UP015
|
||||
18 | pass
|
||||
19 | with open("foo", "r") as f:
|
||||
|
|
||||
@@ -264,12 +264,12 @@ UP015.py:17:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
19 19 | with open("foo", "r") as f:
|
||||
20 20 | pass
|
||||
|
||||
UP015.py:19:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:19:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
17 | with open("foo", "rUb") as f:
|
||||
18 | pass
|
||||
19 | with open("foo", "r") as f:
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
20 | pass
|
||||
21 | with open("foo", "rt") as f:
|
||||
|
|
||||
@@ -285,12 +285,12 @@ UP015.py:19:6: UP015 [*] Unnecessary mode argument
|
||||
21 21 | with open("foo", "rt") as f:
|
||||
22 22 | pass
|
||||
|
||||
UP015.py:21:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:21:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
19 | with open("foo", "r") as f:
|
||||
20 | pass
|
||||
21 | with open("foo", "rt") as f:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
22 | pass
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
|
|
||||
@@ -306,12 +306,12 @@ UP015.py:21:6: UP015 [*] Unnecessary mode argument
|
||||
23 23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
24 24 | pass
|
||||
|
||||
UP015.py:23:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:23:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
21 | with open("foo", "rt") as f:
|
||||
22 | pass
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
24 | pass
|
||||
25 | with open("foo", "wt") as f:
|
||||
|
|
||||
@@ -327,12 +327,12 @@ UP015.py:23:6: UP015 [*] Unnecessary mode argument
|
||||
25 25 | with open("foo", "wt") as f:
|
||||
26 26 | pass
|
||||
|
||||
UP015.py:25:6: UP015 [*] Unnecessary modes, use `w`
|
||||
UP015.py:25:18: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
24 | pass
|
||||
25 | with open("foo", "wt") as f:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
26 | pass
|
||||
|
|
||||
= help: Replace with `w`
|
||||
@@ -347,12 +347,12 @@ UP015.py:25:6: UP015 [*] Unnecessary modes, use `w`
|
||||
27 27 |
|
||||
28 28 | open(f("a", "b", "c"), "U")
|
||||
|
||||
UP015.py:28:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:28:24: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
26 | pass
|
||||
27 |
|
||||
28 | open(f("a", "b", "c"), "U")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
@@ -367,11 +367,11 @@ UP015.py:28:1: UP015 [*] Unnecessary mode argument
|
||||
30 30 |
|
||||
31 31 | with open(f("a", "b", "c"), "U") as f:
|
||||
|
||||
UP015.py:29:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:29:24: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
28 | open(f("a", "b", "c"), "U")
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
30 |
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
|
|
||||
@@ -387,12 +387,12 @@ UP015.py:29:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
31 31 | with open(f("a", "b", "c"), "U") as f:
|
||||
32 32 | pass
|
||||
|
||||
UP015.py:31:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:31:29: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
30 |
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
32 | pass
|
||||
33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
|
|
||||
@@ -408,12 +408,12 @@ UP015.py:31:6: UP015 [*] Unnecessary mode argument
|
||||
33 33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
34 34 | pass
|
||||
|
||||
UP015.py:33:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:33:29: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
32 | pass
|
||||
33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
34 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -428,12 +428,12 @@ UP015.py:33:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
35 35 |
|
||||
36 36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
|
||||
UP015.py:36:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:36:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
34 | pass
|
||||
35 |
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
|
|
||||
@@ -449,12 +449,12 @@ UP015.py:36:6: UP015 [*] Unnecessary mode argument
|
||||
38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
|
||||
UP015.py:36:30: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:36:42: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
34 | pass
|
||||
35 |
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
|
|
||||
@@ -470,12 +470,12 @@ UP015.py:36:30: UP015 [*] Unnecessary mode argument
|
||||
38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
|
||||
UP015.py:38:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:38:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
39 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -490,12 +490,12 @@ UP015.py:38:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
|
||||
UP015.py:38:31: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:38:43: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
| ^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
39 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -510,12 +510,12 @@ UP015.py:38:31: UP015 [*] Unnecessary modes, use `rb`
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
|
||||
UP015.py:41:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:41:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
39 | pass
|
||||
40 |
|
||||
41 | open("foo", mode="U")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
42 | open(name="foo", mode="U")
|
||||
43 | open(mode="U", name="foo")
|
||||
|
|
||||
@@ -531,11 +531,11 @@ UP015.py:41:1: UP015 [*] Unnecessary mode argument
|
||||
43 43 | open(mode="U", name="foo")
|
||||
44 44 |
|
||||
|
||||
UP015.py:42:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:42:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
41 | open("foo", mode="U")
|
||||
42 | open(name="foo", mode="U")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
43 | open(mode="U", name="foo")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
@@ -550,12 +550,12 @@ UP015.py:42:1: UP015 [*] Unnecessary mode argument
|
||||
44 44 |
|
||||
45 45 | with open("foo", mode="U") as f:
|
||||
|
||||
UP015.py:43:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:43:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
41 | open("foo", mode="U")
|
||||
42 | open(name="foo", mode="U")
|
||||
43 | open(mode="U", name="foo")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
44 |
|
||||
45 | with open("foo", mode="U") as f:
|
||||
|
|
||||
@@ -571,12 +571,12 @@ UP015.py:43:1: UP015 [*] Unnecessary mode argument
|
||||
45 45 | with open("foo", mode="U") as f:
|
||||
46 46 | pass
|
||||
|
||||
UP015.py:45:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:45:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
43 | open(mode="U", name="foo")
|
||||
44 |
|
||||
45 | with open("foo", mode="U") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
46 | pass
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
|
|
||||
@@ -592,12 +592,12 @@ UP015.py:45:6: UP015 [*] Unnecessary mode argument
|
||||
47 47 | with open(name="foo", mode="U") as f:
|
||||
48 48 | pass
|
||||
|
||||
UP015.py:47:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:47:28: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
45 | with open("foo", mode="U") as f:
|
||||
46 | pass
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
48 | pass
|
||||
49 | with open(mode="U", name="foo") as f:
|
||||
|
|
||||
@@ -613,12 +613,12 @@ UP015.py:47:6: UP015 [*] Unnecessary mode argument
|
||||
49 49 | with open(mode="U", name="foo") as f:
|
||||
50 50 | pass
|
||||
|
||||
UP015.py:49:6: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:49:16: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
48 | pass
|
||||
49 | with open(mode="U", name="foo") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
50 | pass
|
||||
|
|
||||
= help: Remove mode argument
|
||||
@@ -633,12 +633,12 @@ UP015.py:49:6: UP015 [*] Unnecessary mode argument
|
||||
51 51 |
|
||||
52 52 | open("foo", mode="Ub")
|
||||
|
||||
UP015.py:52:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:52:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
50 | pass
|
||||
51 |
|
||||
52 | open("foo", mode="Ub")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
53 | open(name="foo", mode="Ub")
|
||||
54 | open(mode="Ub", name="foo")
|
||||
|
|
||||
@@ -654,11 +654,11 @@ UP015.py:52:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
54 54 | open(mode="Ub", name="foo")
|
||||
55 55 |
|
||||
|
||||
UP015.py:53:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:53:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
52 | open("foo", mode="Ub")
|
||||
53 | open(name="foo", mode="Ub")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
54 | open(mode="Ub", name="foo")
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -673,12 +673,12 @@ UP015.py:53:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
55 55 |
|
||||
56 56 | with open("foo", mode="Ub") as f:
|
||||
|
||||
UP015.py:54:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:54:11: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
52 | open("foo", mode="Ub")
|
||||
53 | open(name="foo", mode="Ub")
|
||||
54 | open(mode="Ub", name="foo")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
55 |
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
|
|
||||
@@ -694,12 +694,12 @@ UP015.py:54:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
56 56 | with open("foo", mode="Ub") as f:
|
||||
57 57 | pass
|
||||
|
||||
UP015.py:56:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:56:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
54 | open(mode="Ub", name="foo")
|
||||
55 |
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
57 | pass
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
|
|
||||
@@ -715,12 +715,12 @@ UP015.py:56:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
58 58 | with open(name="foo", mode="Ub") as f:
|
||||
59 59 | pass
|
||||
|
||||
UP015.py:58:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:58:28: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
57 | pass
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
59 | pass
|
||||
60 | with open(mode="Ub", name="foo") as f:
|
||||
|
|
||||
@@ -736,12 +736,12 @@ UP015.py:58:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
60 60 | with open(mode="Ub", name="foo") as f:
|
||||
61 61 | pass
|
||||
|
||||
UP015.py:60:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:60:16: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
59 | pass
|
||||
60 | with open(mode="Ub", name="foo") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
61 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -756,12 +756,12 @@ UP015.py:60:6: UP015 [*] Unnecessary modes, use `rb`
|
||||
62 62 |
|
||||
63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:63:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:63:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
61 | pass
|
||||
62 |
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
|
|
||||
@@ -777,11 +777,11 @@ UP015.py:63:1: UP015 [*] Unnecessary mode argument
|
||||
65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:64:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:64:106: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
@@ -797,12 +797,12 @@ UP015.py:64:1: UP015 [*] Unnecessary mode argument
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
|
||||
UP015.py:65:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:65:65: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Remove mode argument
|
||||
@@ -817,12 +817,12 @@ UP015.py:65:1: UP015 [*] Unnecessary mode argument
|
||||
67 67 |
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:66:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:66:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
67 |
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
@@ -838,12 +838,12 @@ UP015.py:66:1: UP015 [*] Unnecessary mode argument
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
|
||||
UP015.py:68:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:68:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 |
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
|
|
||||
@@ -859,11 +859,11 @@ UP015.py:68:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
70 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:69:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:69:106: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
@@ -879,12 +879,12 @@ UP015.py:69:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
72 72 |
|
||||
|
||||
UP015.py:70:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:70:65: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
@@ -899,12 +899,12 @@ UP015.py:70:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
72 72 |
|
||||
73 73 | import aiofiles
|
||||
|
||||
UP015.py:71:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
UP015.py:71:11: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^^ UP015
|
||||
72 |
|
||||
73 | import aiofiles
|
||||
|
|
||||
@@ -920,12 +920,12 @@ UP015.py:71:1: UP015 [*] Unnecessary modes, use `rb`
|
||||
73 73 | import aiofiles
|
||||
74 74 |
|
||||
|
||||
UP015.py:75:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:75:22: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
73 | import aiofiles
|
||||
74 |
|
||||
75 | aiofiles.open("foo", "U")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
76 | aiofiles.open("foo", "r")
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
|
|
||||
@@ -941,11 +941,11 @@ UP015.py:75:1: UP015 [*] Unnecessary mode argument
|
||||
77 77 | aiofiles.open("foo", mode="r")
|
||||
78 78 |
|
||||
|
||||
UP015.py:76:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:76:22: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
75 | aiofiles.open("foo", "U")
|
||||
76 | aiofiles.open("foo", "r")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
@@ -960,12 +960,12 @@ UP015.py:76:1: UP015 [*] Unnecessary mode argument
|
||||
78 78 |
|
||||
79 79 | open("foo", "r+")
|
||||
|
||||
UP015.py:77:1: UP015 [*] Unnecessary mode argument
|
||||
UP015.py:77:27: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
75 | aiofiles.open("foo", "U")
|
||||
76 | aiofiles.open("foo", "r")
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
78 |
|
||||
79 | open("foo", "r+")
|
||||
|
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
|
||||
---
|
||||
UP015_1.py:3:5: UP015 [*] Unnecessary mode argument
|
||||
UP015_1.py:3:17: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | # Not a valid type annotation but this test shouldn't result in a panic.
|
||||
2 | # Refer: https://github.com/astral-sh/ruff/issues/11736
|
||||
3 | x: 'open("foo", "r")'
|
||||
| ^^^^^^^^^^^^^^^^ UP015
|
||||
| ^^^ UP015
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
|
||||
@@ -1,982 +0,0 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
|
||||
---
|
||||
UP015.py:1:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
| ^^^ UP015
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
1 |-open("foo", "U")
|
||||
1 |+open("foo")
|
||||
2 2 | open("foo", "Ur")
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
|
||||
UP015.py:2:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
2 | open("foo", "Ur")
|
||||
| ^^^^ UP015
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | open("foo", "U")
|
||||
2 |-open("foo", "Ur")
|
||||
2 |+open("foo")
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
|
||||
UP015.py:3:13: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
1 | open("foo", "U")
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
| ^^^^ UP015
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | open("foo", "U")
|
||||
2 2 | open("foo", "Ur")
|
||||
3 |-open("foo", "Ub")
|
||||
3 |+open("foo", "rb")
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
|
||||
UP015.py:4:13: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
2 | open("foo", "Ur")
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
| ^^^^^ UP015
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | open("foo", "U")
|
||||
2 2 | open("foo", "Ur")
|
||||
3 3 | open("foo", "Ub")
|
||||
4 |-open("foo", "rUb")
|
||||
4 |+open("foo", "rb")
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
|
||||
UP015.py:5:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
3 | open("foo", "Ub")
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
| ^^^ UP015
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
2 2 | open("foo", "Ur")
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
5 |-open("foo", "r")
|
||||
5 |+open("foo")
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
|
||||
UP015.py:6:13: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
4 | open("foo", "rUb")
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
| ^^^^ UP015
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
6 |-open("foo", "rt")
|
||||
6 |+open("foo")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
9 9 | open("f", "tw")
|
||||
|
||||
UP015.py:7:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
5 | open("foo", "r")
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
| ^^^ UP015
|
||||
8 | open("f", "wt")
|
||||
9 | open("f", "tw")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
7 |-open("f", "r", encoding="UTF-8")
|
||||
7 |+open("f", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
9 9 | open("f", "tw")
|
||||
10 10 |
|
||||
|
||||
UP015.py:8:11: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
6 | open("foo", "rt")
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
| ^^^^ UP015
|
||||
9 | open("f", "tw")
|
||||
|
|
||||
= help: Replace with `w`
|
||||
|
||||
ℹ Safe fix
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 |-open("f", "wt")
|
||||
8 |+open("f", "w")
|
||||
9 9 | open("f", "tw")
|
||||
10 10 |
|
||||
11 11 | with open("foo", "U") as f:
|
||||
|
||||
UP015.py:9:11: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
7 | open("f", "r", encoding="UTF-8")
|
||||
8 | open("f", "wt")
|
||||
9 | open("f", "tw")
|
||||
| ^^^^ UP015
|
||||
10 |
|
||||
11 | with open("foo", "U") as f:
|
||||
|
|
||||
= help: Replace with `w`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
9 |-open("f", "tw")
|
||||
9 |+open("f", "w")
|
||||
10 10 |
|
||||
11 11 | with open("foo", "U") as f:
|
||||
12 12 | pass
|
||||
|
||||
UP015.py:11:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
9 | open("f", "tw")
|
||||
10 |
|
||||
11 | with open("foo", "U") as f:
|
||||
| ^^^ UP015
|
||||
12 | pass
|
||||
13 | with open("foo", "Ur") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
8 8 | open("f", "wt")
|
||||
9 9 | open("f", "tw")
|
||||
10 10 |
|
||||
11 |-with open("foo", "U") as f:
|
||||
11 |+with open("foo") as f:
|
||||
12 12 | pass
|
||||
13 13 | with open("foo", "Ur") as f:
|
||||
14 14 | pass
|
||||
|
||||
UP015.py:13:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
11 | with open("foo", "U") as f:
|
||||
12 | pass
|
||||
13 | with open("foo", "Ur") as f:
|
||||
| ^^^^ UP015
|
||||
14 | pass
|
||||
15 | with open("foo", "Ub") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 |
|
||||
11 11 | with open("foo", "U") as f:
|
||||
12 12 | pass
|
||||
13 |-with open("foo", "Ur") as f:
|
||||
13 |+with open("foo") as f:
|
||||
14 14 | pass
|
||||
15 15 | with open("foo", "Ub") as f:
|
||||
16 16 | pass
|
||||
|
||||
UP015.py:15:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
13 | with open("foo", "Ur") as f:
|
||||
14 | pass
|
||||
15 | with open("foo", "Ub") as f:
|
||||
| ^^^^ UP015
|
||||
16 | pass
|
||||
17 | with open("foo", "rUb") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
12 12 | pass
|
||||
13 13 | with open("foo", "Ur") as f:
|
||||
14 14 | pass
|
||||
15 |-with open("foo", "Ub") as f:
|
||||
15 |+with open("foo", "rb") as f:
|
||||
16 16 | pass
|
||||
17 17 | with open("foo", "rUb") as f:
|
||||
18 18 | pass
|
||||
|
||||
UP015.py:17:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
15 | with open("foo", "Ub") as f:
|
||||
16 | pass
|
||||
17 | with open("foo", "rUb") as f:
|
||||
| ^^^^^ UP015
|
||||
18 | pass
|
||||
19 | with open("foo", "r") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
14 14 | pass
|
||||
15 15 | with open("foo", "Ub") as f:
|
||||
16 16 | pass
|
||||
17 |-with open("foo", "rUb") as f:
|
||||
17 |+with open("foo", "rb") as f:
|
||||
18 18 | pass
|
||||
19 19 | with open("foo", "r") as f:
|
||||
20 20 | pass
|
||||
|
||||
UP015.py:19:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
17 | with open("foo", "rUb") as f:
|
||||
18 | pass
|
||||
19 | with open("foo", "r") as f:
|
||||
| ^^^ UP015
|
||||
20 | pass
|
||||
21 | with open("foo", "rt") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
16 16 | pass
|
||||
17 17 | with open("foo", "rUb") as f:
|
||||
18 18 | pass
|
||||
19 |-with open("foo", "r") as f:
|
||||
19 |+with open("foo") as f:
|
||||
20 20 | pass
|
||||
21 21 | with open("foo", "rt") as f:
|
||||
22 22 | pass
|
||||
|
||||
UP015.py:21:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
19 | with open("foo", "r") as f:
|
||||
20 | pass
|
||||
21 | with open("foo", "rt") as f:
|
||||
| ^^^^ UP015
|
||||
22 | pass
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
18 18 | pass
|
||||
19 19 | with open("foo", "r") as f:
|
||||
20 20 | pass
|
||||
21 |-with open("foo", "rt") as f:
|
||||
21 |+with open("foo") as f:
|
||||
22 22 | pass
|
||||
23 23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
24 24 | pass
|
||||
|
||||
UP015.py:23:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
21 | with open("foo", "rt") as f:
|
||||
22 | pass
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
| ^^^ UP015
|
||||
24 | pass
|
||||
25 | with open("foo", "wt") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
20 20 | pass
|
||||
21 21 | with open("foo", "rt") as f:
|
||||
22 22 | pass
|
||||
23 |-with open("foo", "r", encoding="UTF-8") as f:
|
||||
23 |+with open("foo", encoding="UTF-8") as f:
|
||||
24 24 | pass
|
||||
25 25 | with open("foo", "wt") as f:
|
||||
26 26 | pass
|
||||
|
||||
UP015.py:25:18: UP015 [*] Unnecessary modes, use `w`
|
||||
|
|
||||
23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
24 | pass
|
||||
25 | with open("foo", "wt") as f:
|
||||
| ^^^^ UP015
|
||||
26 | pass
|
||||
|
|
||||
= help: Replace with `w`
|
||||
|
||||
ℹ Safe fix
|
||||
22 22 | pass
|
||||
23 23 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
24 24 | pass
|
||||
25 |-with open("foo", "wt") as f:
|
||||
25 |+with open("foo", "w") as f:
|
||||
26 26 | pass
|
||||
27 27 |
|
||||
28 28 | open(f("a", "b", "c"), "U")
|
||||
|
||||
UP015.py:28:24: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
26 | pass
|
||||
27 |
|
||||
28 | open(f("a", "b", "c"), "U")
|
||||
| ^^^ UP015
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
25 25 | with open("foo", "wt") as f:
|
||||
26 26 | pass
|
||||
27 27 |
|
||||
28 |-open(f("a", "b", "c"), "U")
|
||||
28 |+open(f("a", "b", "c"))
|
||||
29 29 | open(f("a", "b", "c"), "Ub")
|
||||
30 30 |
|
||||
31 31 | with open(f("a", "b", "c"), "U") as f:
|
||||
|
||||
UP015.py:29:24: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
28 | open(f("a", "b", "c"), "U")
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
| ^^^^ UP015
|
||||
30 |
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
26 26 | pass
|
||||
27 27 |
|
||||
28 28 | open(f("a", "b", "c"), "U")
|
||||
29 |-open(f("a", "b", "c"), "Ub")
|
||||
29 |+open(f("a", "b", "c"), "rb")
|
||||
30 30 |
|
||||
31 31 | with open(f("a", "b", "c"), "U") as f:
|
||||
32 32 | pass
|
||||
|
||||
UP015.py:31:29: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
29 | open(f("a", "b", "c"), "Ub")
|
||||
30 |
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
| ^^^ UP015
|
||||
32 | pass
|
||||
33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
28 28 | open(f("a", "b", "c"), "U")
|
||||
29 29 | open(f("a", "b", "c"), "Ub")
|
||||
30 30 |
|
||||
31 |-with open(f("a", "b", "c"), "U") as f:
|
||||
31 |+with open(f("a", "b", "c")) as f:
|
||||
32 32 | pass
|
||||
33 33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
34 34 | pass
|
||||
|
||||
UP015.py:33:29: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
31 | with open(f("a", "b", "c"), "U") as f:
|
||||
32 | pass
|
||||
33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
| ^^^^ UP015
|
||||
34 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
30 30 |
|
||||
31 31 | with open(f("a", "b", "c"), "U") as f:
|
||||
32 32 | pass
|
||||
33 |-with open(f("a", "b", "c"), "Ub") as f:
|
||||
33 |+with open(f("a", "b", "c"), "rb") as f:
|
||||
34 34 | pass
|
||||
35 35 |
|
||||
36 36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
|
||||
UP015.py:36:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
34 | pass
|
||||
35 |
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
| ^^^ UP015
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
33 33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
34 34 | pass
|
||||
35 35 |
|
||||
36 |-with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
36 |+with open("foo") as fa, open("bar", "U") as fb:
|
||||
37 37 | pass
|
||||
38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
|
||||
UP015.py:36:42: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
34 | pass
|
||||
35 |
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
| ^^^ UP015
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
33 33 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
34 34 | pass
|
||||
35 35 |
|
||||
36 |-with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
36 |+with open("foo", "U") as fa, open("bar") as fb:
|
||||
37 37 | pass
|
||||
38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
|
||||
UP015.py:38:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
| ^^^^ UP015
|
||||
39 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
35 35 |
|
||||
36 36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 37 | pass
|
||||
38 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
38 |+with open("foo", "rb") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
|
||||
UP015.py:38:43: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 | pass
|
||||
38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
| ^^^^ UP015
|
||||
39 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
35 35 |
|
||||
36 36 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
37 37 | pass
|
||||
38 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
38 |+with open("foo", "Ub") as fa, open("bar", "rb") as fb:
|
||||
39 39 | pass
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
|
||||
UP015.py:41:18: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
39 | pass
|
||||
40 |
|
||||
41 | open("foo", mode="U")
|
||||
| ^^^ UP015
|
||||
42 | open(name="foo", mode="U")
|
||||
43 | open(mode="U", name="foo")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
39 39 | pass
|
||||
40 40 |
|
||||
41 |-open("foo", mode="U")
|
||||
41 |+open("foo")
|
||||
42 42 | open(name="foo", mode="U")
|
||||
43 43 | open(mode="U", name="foo")
|
||||
44 44 |
|
||||
|
||||
UP015.py:42:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
41 | open("foo", mode="U")
|
||||
42 | open(name="foo", mode="U")
|
||||
| ^^^ UP015
|
||||
43 | open(mode="U", name="foo")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
39 39 | pass
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
42 |-open(name="foo", mode="U")
|
||||
42 |+open(name="foo")
|
||||
43 43 | open(mode="U", name="foo")
|
||||
44 44 |
|
||||
45 45 | with open("foo", mode="U") as f:
|
||||
|
||||
UP015.py:43:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
41 | open("foo", mode="U")
|
||||
42 | open(name="foo", mode="U")
|
||||
43 | open(mode="U", name="foo")
|
||||
| ^^^ UP015
|
||||
44 |
|
||||
45 | with open("foo", mode="U") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
40 40 |
|
||||
41 41 | open("foo", mode="U")
|
||||
42 42 | open(name="foo", mode="U")
|
||||
43 |-open(mode="U", name="foo")
|
||||
43 |+open(name="foo")
|
||||
44 44 |
|
||||
45 45 | with open("foo", mode="U") as f:
|
||||
46 46 | pass
|
||||
|
||||
UP015.py:45:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
43 | open(mode="U", name="foo")
|
||||
44 |
|
||||
45 | with open("foo", mode="U") as f:
|
||||
| ^^^ UP015
|
||||
46 | pass
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
42 42 | open(name="foo", mode="U")
|
||||
43 43 | open(mode="U", name="foo")
|
||||
44 44 |
|
||||
45 |-with open("foo", mode="U") as f:
|
||||
45 |+with open("foo") as f:
|
||||
46 46 | pass
|
||||
47 47 | with open(name="foo", mode="U") as f:
|
||||
48 48 | pass
|
||||
|
||||
UP015.py:47:28: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
45 | with open("foo", mode="U") as f:
|
||||
46 | pass
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
| ^^^ UP015
|
||||
48 | pass
|
||||
49 | with open(mode="U", name="foo") as f:
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
44 44 |
|
||||
45 45 | with open("foo", mode="U") as f:
|
||||
46 46 | pass
|
||||
47 |-with open(name="foo", mode="U") as f:
|
||||
47 |+with open(name="foo") as f:
|
||||
48 48 | pass
|
||||
49 49 | with open(mode="U", name="foo") as f:
|
||||
50 50 | pass
|
||||
|
||||
UP015.py:49:16: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
47 | with open(name="foo", mode="U") as f:
|
||||
48 | pass
|
||||
49 | with open(mode="U", name="foo") as f:
|
||||
| ^^^ UP015
|
||||
50 | pass
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
46 46 | pass
|
||||
47 47 | with open(name="foo", mode="U") as f:
|
||||
48 48 | pass
|
||||
49 |-with open(mode="U", name="foo") as f:
|
||||
49 |+with open(name="foo") as f:
|
||||
50 50 | pass
|
||||
51 51 |
|
||||
52 52 | open("foo", mode="Ub")
|
||||
|
||||
UP015.py:52:18: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
50 | pass
|
||||
51 |
|
||||
52 | open("foo", mode="Ub")
|
||||
| ^^^^ UP015
|
||||
53 | open(name="foo", mode="Ub")
|
||||
54 | open(mode="Ub", name="foo")
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
49 49 | with open(mode="U", name="foo") as f:
|
||||
50 50 | pass
|
||||
51 51 |
|
||||
52 |-open("foo", mode="Ub")
|
||||
52 |+open("foo", mode="rb")
|
||||
53 53 | open(name="foo", mode="Ub")
|
||||
54 54 | open(mode="Ub", name="foo")
|
||||
55 55 |
|
||||
|
||||
UP015.py:53:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
52 | open("foo", mode="Ub")
|
||||
53 | open(name="foo", mode="Ub")
|
||||
| ^^^^ UP015
|
||||
54 | open(mode="Ub", name="foo")
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
50 50 | pass
|
||||
51 51 |
|
||||
52 52 | open("foo", mode="Ub")
|
||||
53 |-open(name="foo", mode="Ub")
|
||||
53 |+open(name="foo", mode="rb")
|
||||
54 54 | open(mode="Ub", name="foo")
|
||||
55 55 |
|
||||
56 56 | with open("foo", mode="Ub") as f:
|
||||
|
||||
UP015.py:54:11: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
52 | open("foo", mode="Ub")
|
||||
53 | open(name="foo", mode="Ub")
|
||||
54 | open(mode="Ub", name="foo")
|
||||
| ^^^^ UP015
|
||||
55 |
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
51 51 |
|
||||
52 52 | open("foo", mode="Ub")
|
||||
53 53 | open(name="foo", mode="Ub")
|
||||
54 |-open(mode="Ub", name="foo")
|
||||
54 |+open(mode="rb", name="foo")
|
||||
55 55 |
|
||||
56 56 | with open("foo", mode="Ub") as f:
|
||||
57 57 | pass
|
||||
|
||||
UP015.py:56:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
54 | open(mode="Ub", name="foo")
|
||||
55 |
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
| ^^^^ UP015
|
||||
57 | pass
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
53 53 | open(name="foo", mode="Ub")
|
||||
54 54 | open(mode="Ub", name="foo")
|
||||
55 55 |
|
||||
56 |-with open("foo", mode="Ub") as f:
|
||||
56 |+with open("foo", mode="rb") as f:
|
||||
57 57 | pass
|
||||
58 58 | with open(name="foo", mode="Ub") as f:
|
||||
59 59 | pass
|
||||
|
||||
UP015.py:58:28: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
56 | with open("foo", mode="Ub") as f:
|
||||
57 | pass
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
| ^^^^ UP015
|
||||
59 | pass
|
||||
60 | with open(mode="Ub", name="foo") as f:
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
55 55 |
|
||||
56 56 | with open("foo", mode="Ub") as f:
|
||||
57 57 | pass
|
||||
58 |-with open(name="foo", mode="Ub") as f:
|
||||
58 |+with open(name="foo", mode="rb") as f:
|
||||
59 59 | pass
|
||||
60 60 | with open(mode="Ub", name="foo") as f:
|
||||
61 61 | pass
|
||||
|
||||
UP015.py:60:16: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
58 | with open(name="foo", mode="Ub") as f:
|
||||
59 | pass
|
||||
60 | with open(mode="Ub", name="foo") as f:
|
||||
| ^^^^ UP015
|
||||
61 | pass
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
57 57 | pass
|
||||
58 58 | with open(name="foo", mode="Ub") as f:
|
||||
59 59 | pass
|
||||
60 |-with open(mode="Ub", name="foo") as f:
|
||||
60 |+with open(mode="rb", name="foo") as f:
|
||||
61 61 | pass
|
||||
62 62 |
|
||||
63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:63:23: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
61 | pass
|
||||
62 |
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^ UP015
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
60 60 | with open(mode="Ub", name="foo") as f:
|
||||
61 61 | pass
|
||||
62 62 |
|
||||
63 |-open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
63 |+open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:64:106: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
| ^^^ UP015
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
61 61 | pass
|
||||
62 62 |
|
||||
63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 |-open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
64 |+open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
|
||||
UP015.py:65:65: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
| ^^^ UP015
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
62 62 |
|
||||
63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 |-open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
65 |+open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:66:11: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^ UP015
|
||||
67 |
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
64 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 |-open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
66 |+open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
|
||||
UP015.py:68:23: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 |
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^ UP015
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
68 |-open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
68 |+open(file="foo", mode="rb", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
||||
UP015.py:69:106: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
| ^^^^ UP015
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
67 67 |
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 |-open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
69 |+open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode="rb")
|
||||
70 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
72 72 |
|
||||
|
||||
UP015.py:70:65: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
| ^^^^ UP015
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
67 67 |
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 |-open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
70 |+open(file="foo", buffering=-1, encoding=None, errors=None, mode="rb", newline=None, closefd=True, opener=None)
|
||||
71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
72 72 |
|
||||
73 73 | import aiofiles
|
||||
|
||||
UP015.py:71:11: UP015 [*] Unnecessary modes, use `rb`
|
||||
|
|
||||
69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
| ^^^^ UP015
|
||||
72 |
|
||||
73 | import aiofiles
|
||||
|
|
||||
= help: Replace with `rb`
|
||||
|
||||
ℹ Safe fix
|
||||
68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
70 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
71 |-open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
71 |+open(mode="rb", file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
72 72 |
|
||||
73 73 | import aiofiles
|
||||
74 74 |
|
||||
|
||||
UP015.py:75:22: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
73 | import aiofiles
|
||||
74 |
|
||||
75 | aiofiles.open("foo", "U")
|
||||
| ^^^ UP015
|
||||
76 | aiofiles.open("foo", "r")
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
72 72 |
|
||||
73 73 | import aiofiles
|
||||
74 74 |
|
||||
75 |-aiofiles.open("foo", "U")
|
||||
75 |+aiofiles.open("foo")
|
||||
76 76 | aiofiles.open("foo", "r")
|
||||
77 77 | aiofiles.open("foo", mode="r")
|
||||
78 78 |
|
||||
|
||||
UP015.py:76:22: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
75 | aiofiles.open("foo", "U")
|
||||
76 | aiofiles.open("foo", "r")
|
||||
| ^^^ UP015
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
73 73 | import aiofiles
|
||||
74 74 |
|
||||
75 75 | aiofiles.open("foo", "U")
|
||||
76 |-aiofiles.open("foo", "r")
|
||||
76 |+aiofiles.open("foo")
|
||||
77 77 | aiofiles.open("foo", mode="r")
|
||||
78 78 |
|
||||
79 79 | open("foo", "r+")
|
||||
|
||||
UP015.py:77:27: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
75 | aiofiles.open("foo", "U")
|
||||
76 | aiofiles.open("foo", "r")
|
||||
77 | aiofiles.open("foo", mode="r")
|
||||
| ^^^ UP015
|
||||
78 |
|
||||
79 | open("foo", "r+")
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
74 74 |
|
||||
75 75 | aiofiles.open("foo", "U")
|
||||
76 76 | aiofiles.open("foo", "r")
|
||||
77 |-aiofiles.open("foo", mode="r")
|
||||
77 |+aiofiles.open("foo")
|
||||
78 78 |
|
||||
79 79 | open("foo", "r+")
|
||||
80 80 | open("foo", "rb")
|
||||
@@ -1,18 +0,0 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
|
||||
---
|
||||
UP015_1.py:3:17: UP015 [*] Unnecessary mode argument
|
||||
|
|
||||
1 | # Not a valid type annotation but this test shouldn't result in a panic.
|
||||
2 | # Refer: https://github.com/astral-sh/ruff/issues/11736
|
||||
3 | x: 'open("foo", "r")'
|
||||
| ^^^ UP015
|
||||
|
|
||||
= help: Remove mode argument
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Not a valid type annotation but this test shouldn't result in a panic.
|
||||
2 2 | # Refer: https://github.com/astral-sh/ruff/issues/11736
|
||||
3 |-x: 'open("foo", "r")'
|
||||
3 |+x: 'open("foo")'
|
||||
4 4 |
|
||||
Reference in New Issue
Block a user