mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
Render tabs as 4 spaces in diagnostics (#4132)
This commit is contained in:
parent
ac600bb3da
commit
b14358fbfe
13 changed files with 229 additions and 176 deletions
|
@ -8,7 +8,8 @@ use bitflags::bitflags;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use ruff_diagnostics::DiagnosticKind;
|
use ruff_diagnostics::DiagnosticKind;
|
||||||
use ruff_python_ast::source_code::{OneIndexed, SourceLocation};
|
use ruff_python_ast::source_code::{OneIndexed, SourceLocation};
|
||||||
use ruff_text_size::TextRange;
|
use ruff_text_size::{TextRange, TextSize};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
@ -172,6 +173,7 @@ impl Display for MessageCodeFrame<'_> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let source_code = file.to_source_code();
|
let source_code = file.to_source_code();
|
||||||
|
|
||||||
let content_start_index = source_code.line_index(range.start());
|
let content_start_index = source_code.line_index(range.start());
|
||||||
let mut start_index = content_start_index.saturating_sub(2);
|
let mut start_index = content_start_index.saturating_sub(2);
|
||||||
|
|
||||||
|
@ -200,26 +202,23 @@ impl Display for MessageCodeFrame<'_> {
|
||||||
let start_offset = source_code.line_start(start_index);
|
let start_offset = source_code.line_start(start_index);
|
||||||
let end_offset = source_code.line_end(end_index);
|
let end_offset = source_code.line_end(end_index);
|
||||||
|
|
||||||
let source_text = source_code.slice(TextRange::new(start_offset, end_offset));
|
let source = replace_whitespace(
|
||||||
|
source_code.slice(TextRange::new(start_offset, end_offset)),
|
||||||
|
range - start_offset,
|
||||||
|
);
|
||||||
|
|
||||||
let annotation_start_offset = range.start() - start_offset;
|
let start_char = source.text[TextRange::up_to(source.annotation_range.start())]
|
||||||
let annotation_end_offset = range.end() - start_offset;
|
|
||||||
|
|
||||||
let start_char = source_text[TextRange::up_to(annotation_start_offset)]
|
|
||||||
.chars()
|
.chars()
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
let char_length = source_text
|
let char_length = source.text[source.annotation_range].chars().count();
|
||||||
[TextRange::new(annotation_start_offset, annotation_end_offset)]
|
|
||||||
.chars()
|
|
||||||
.count();
|
|
||||||
|
|
||||||
let label = kind.rule().noqa_code().to_string();
|
let label = kind.rule().noqa_code().to_string();
|
||||||
|
|
||||||
let snippet = Snippet {
|
let snippet = Snippet {
|
||||||
title: None,
|
title: None,
|
||||||
slices: vec![Slice {
|
slices: vec![Slice {
|
||||||
source: source_text,
|
source: &source.text,
|
||||||
line_start: content_start_index.get(),
|
line_start: content_start_index.get(),
|
||||||
annotations: vec![SourceAnnotation {
|
annotations: vec![SourceAnnotation {
|
||||||
label: &label,
|
label: &label,
|
||||||
|
@ -245,6 +244,60 @@ impl Display for MessageCodeFrame<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn replace_whitespace(source: &str, annotation_range: TextRange) -> SourceCode {
|
||||||
|
static TAB_SIZE: TextSize = TextSize::new(4);
|
||||||
|
|
||||||
|
let mut result = String::new();
|
||||||
|
let mut last_end = 0;
|
||||||
|
let mut range = annotation_range;
|
||||||
|
let mut column = 0;
|
||||||
|
|
||||||
|
for (index, m) in source.match_indices(['\t', '\n', '\r']) {
|
||||||
|
match m {
|
||||||
|
"\t" => {
|
||||||
|
let tab_width = TAB_SIZE - TextSize::new(column % 4);
|
||||||
|
|
||||||
|
if index < usize::from(annotation_range.start()) {
|
||||||
|
range += tab_width - TextSize::new(1);
|
||||||
|
} else if index < usize::from(annotation_range.end()) {
|
||||||
|
range = range.add_end(tab_width - TextSize::new(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push_str(&source[last_end..index]);
|
||||||
|
|
||||||
|
for _ in 0..u32::from(tab_width) {
|
||||||
|
result.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
last_end = index + 1;
|
||||||
|
}
|
||||||
|
"\n" | "\r" => {
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No tabs
|
||||||
|
if result.is_empty() {
|
||||||
|
SourceCode {
|
||||||
|
annotation_range,
|
||||||
|
text: Cow::Borrowed(source),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.push_str(&source[last_end..]);
|
||||||
|
SourceCode {
|
||||||
|
annotation_range: range,
|
||||||
|
text: Cow::Owned(result),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SourceCode<'a> {
|
||||||
|
text: Cow<'a, str>,
|
||||||
|
annotation_range: TextRange,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::message::tests::{capture_emitter_output, create_messages};
|
use crate::message::tests::{capture_emitter_output, create_messages};
|
||||||
|
|
|
@ -5,8 +5,8 @@ E101.py:11:1: E101 Indentation contains mixed spaces and tabs
|
||||||
|
|
|
|
||||||
11 | def func_mixed_start_with_tab():
|
11 | def func_mixed_start_with_tab():
|
||||||
12 | # E101
|
12 | # E101
|
||||||
13 | print("mixed starts with tab")
|
13 | print("mixed starts with tab")
|
||||||
| ^^ E101
|
| ^^^^^^ E101
|
||||||
14 |
|
14 |
|
||||||
15 | def func_mixed_start_with_space():
|
15 | def func_mixed_start_with_space():
|
||||||
|
|
|
|
||||||
|
@ -15,8 +15,8 @@ E101.py:15:1: E101 Indentation contains mixed spaces and tabs
|
||||||
|
|
|
|
||||||
15 | def func_mixed_start_with_space():
|
15 | def func_mixed_start_with_space():
|
||||||
16 | # E101
|
16 | # E101
|
||||||
17 | print("mixed starts with space")
|
17 | print("mixed starts with space")
|
||||||
| ^^^^^^^^ E101
|
| ^^^^^^^^^^^^^^^^^^^^ E101
|
||||||
18 |
|
18 |
|
||||||
19 | def xyz():
|
19 | def xyz():
|
||||||
|
|
|
|
||||||
|
@ -25,8 +25,8 @@ E101.py:19:1: E101 Indentation contains mixed spaces and tabs
|
||||||
|
|
|
|
||||||
19 | def xyz():
|
19 | def xyz():
|
||||||
20 | # E101
|
20 | # E101
|
||||||
21 | print("xyz");
|
21 | print("xyz");
|
||||||
| ^^^ E101
|
| ^^^^^^^ E101
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ E11.py:42:1: E117 Over-indented
|
||||||
|
|
|
|
||||||
42 | #: E117 W191
|
42 | #: E117 W191
|
||||||
43 | def start():
|
43 | def start():
|
||||||
44 | print()
|
44 | print()
|
||||||
| E117
|
| ^^^^^^^^ E117
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,34 +27,34 @@ E20.py:6:15: E201 Whitespace after '('
|
||||||
8 | spam(ham[1], { eggs: 2})
|
8 | spam(ham[1], { eggs: 2})
|
||||||
| E201
|
| E201
|
||||||
9 | #: E201:1:6
|
9 | #: E201:1:6
|
||||||
10 | spam( ham[1], {eggs: 2})
|
10 | spam( ham[1], {eggs: 2})
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:8:6: E201 Whitespace after '('
|
E20.py:8:6: E201 Whitespace after '('
|
||||||
|
|
|
|
||||||
8 | spam(ham[1], { eggs: 2})
|
8 | spam(ham[1], { eggs: 2})
|
||||||
9 | #: E201:1:6
|
9 | #: E201:1:6
|
||||||
10 | spam( ham[1], {eggs: 2})
|
10 | spam( ham[1], {eggs: 2})
|
||||||
| E201
|
| E201
|
||||||
11 | #: E201:1:10
|
11 | #: E201:1:10
|
||||||
12 | spam(ham[ 1], {eggs: 2})
|
12 | spam(ham[ 1], {eggs: 2})
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:10:10: E201 Whitespace after '('
|
E20.py:10:10: E201 Whitespace after '('
|
||||||
|
|
|
|
||||||
10 | spam( ham[1], {eggs: 2})
|
10 | spam( ham[1], {eggs: 2})
|
||||||
11 | #: E201:1:10
|
11 | #: E201:1:10
|
||||||
12 | spam(ham[ 1], {eggs: 2})
|
12 | spam(ham[ 1], {eggs: 2})
|
||||||
| E201
|
| E201
|
||||||
13 | #: E201:1:15
|
13 | #: E201:1:15
|
||||||
14 | spam(ham[1], { eggs: 2})
|
14 | spam(ham[1], { eggs: 2})
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:12:15: E201 Whitespace after '('
|
E20.py:12:15: E201 Whitespace after '('
|
||||||
|
|
|
|
||||||
12 | spam(ham[ 1], {eggs: 2})
|
12 | spam(ham[ 1], {eggs: 2})
|
||||||
13 | #: E201:1:15
|
13 | #: E201:1:15
|
||||||
14 | spam(ham[1], { eggs: 2})
|
14 | spam(ham[1], { eggs: 2})
|
||||||
| E201
|
| E201
|
||||||
15 | #: Okay
|
15 | #: Okay
|
||||||
16 | spam(ham[1], {eggs: 2})
|
16 | spam(ham[1], {eggs: 2})
|
||||||
|
|
|
@ -27,34 +27,34 @@ E20.py:23:11: E202 Whitespace before ')'
|
||||||
25 | spam(ham[1 ], {eggs: 2})
|
25 | spam(ham[1 ], {eggs: 2})
|
||||||
| E202
|
| E202
|
||||||
26 | #: E202:1:23
|
26 | #: E202:1:23
|
||||||
27 | spam(ham[1], {eggs: 2} )
|
27 | spam(ham[1], {eggs: 2} )
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:25:23: E202 Whitespace before ')'
|
E20.py:25:23: E202 Whitespace before ')'
|
||||||
|
|
|
|
||||||
25 | spam(ham[1 ], {eggs: 2})
|
25 | spam(ham[1 ], {eggs: 2})
|
||||||
26 | #: E202:1:23
|
26 | #: E202:1:23
|
||||||
27 | spam(ham[1], {eggs: 2} )
|
27 | spam(ham[1], {eggs: 2} )
|
||||||
| E202
|
| E202
|
||||||
28 | #: E202:1:22
|
28 | #: E202:1:22
|
||||||
29 | spam(ham[1], {eggs: 2 })
|
29 | spam(ham[1], {eggs: 2 })
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:27:22: E202 Whitespace before ')'
|
E20.py:27:22: E202 Whitespace before ')'
|
||||||
|
|
|
|
||||||
27 | spam(ham[1], {eggs: 2} )
|
27 | spam(ham[1], {eggs: 2} )
|
||||||
28 | #: E202:1:22
|
28 | #: E202:1:22
|
||||||
29 | spam(ham[1], {eggs: 2 })
|
29 | spam(ham[1], {eggs: 2 })
|
||||||
| E202
|
| E202
|
||||||
30 | #: E202:1:11
|
30 | #: E202:1:11
|
||||||
31 | spam(ham[1 ], {eggs: 2})
|
31 | spam(ham[1 ], {eggs: 2})
|
||||||
|
|
|
|
||||||
|
|
||||||
E20.py:29:11: E202 Whitespace before ')'
|
E20.py:29:11: E202 Whitespace before ')'
|
||||||
|
|
|
|
||||||
29 | spam(ham[1], {eggs: 2 })
|
29 | spam(ham[1], {eggs: 2 })
|
||||||
30 | #: E202:1:11
|
30 | #: E202:1:11
|
||||||
31 | spam(ham[1 ], {eggs: 2})
|
31 | spam(ham[1 ], {eggs: 2})
|
||||||
| E202
|
| E202
|
||||||
32 | #: Okay
|
32 | #: Okay
|
||||||
33 | spam(ham[1], {eggs: 2})
|
33 | spam(ham[1], {eggs: 2})
|
||||||
|
|
|
@ -14,7 +14,7 @@ E20.py:55:10: E203 Whitespace before ',', ';', or ':'
|
||||||
|
|
|
|
||||||
55 | x, y = y, x
|
55 | x, y = y, x
|
||||||
56 | #: E203:1:10
|
56 | #: E203:1:10
|
||||||
57 | if x == 4 :
|
57 | if x == 4 :
|
||||||
| E203
|
| E203
|
||||||
58 | print x, y
|
58 | print x, y
|
||||||
59 | x, y = y, x
|
59 | x, y = y, x
|
||||||
|
@ -34,7 +34,7 @@ E20.py:63:15: E203 Whitespace before ',', ';', or ':'
|
||||||
|
|
|
|
||||||
63 | #: E203:2:15 E702:2:16
|
63 | #: E203:2:15 E702:2:16
|
||||||
64 | if x == 4:
|
64 | if x == 4:
|
||||||
65 | print x, y ; x, y = y, x
|
65 | print x, y ; x, y = y, x
|
||||||
| E203
|
| E203
|
||||||
66 | #: E203:3:13
|
66 | #: E203:3:13
|
||||||
67 | if x == 4:
|
67 | if x == 4:
|
||||||
|
@ -54,7 +54,7 @@ E20.py:71:13: E203 Whitespace before ',', ';', or ':'
|
||||||
|
|
|
|
||||||
71 | if x == 4:
|
71 | if x == 4:
|
||||||
72 | print x, y
|
72 | print x, y
|
||||||
73 | x, y = y , x
|
73 | x, y = y , x
|
||||||
| E203
|
| E203
|
||||||
74 | #: Okay
|
74 | #: Okay
|
||||||
75 | if x == 4:
|
75 | if x == 4:
|
||||||
|
|
|
@ -5,7 +5,7 @@ E22.py:43:2: E223 Tab before operator
|
||||||
|
|
|
|
||||||
43 | #: E223
|
43 | #: E223
|
||||||
44 | foobart = 4
|
44 | foobart = 4
|
||||||
45 | a = 3 # aligned with tab
|
45 | a = 3 # aligned with tab
|
||||||
| E223
|
| E223
|
||||||
46 | #:
|
46 | #:
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs
|
||||||
E22.py:48:5: E224 Tab after operator
|
E22.py:48:5: E224 Tab after operator
|
||||||
|
|
|
|
||||||
48 | #: E224
|
48 | #: E224
|
||||||
49 | a += 1
|
49 | a += 1
|
||||||
| E224
|
| E224
|
||||||
50 | b += 1000
|
50 | b += 1000
|
||||||
51 | #:
|
51 | #:
|
||||||
|
|
|
@ -28,12 +28,12 @@ E27.py:8:3: E271 Multiple spaces after keyword
|
||||||
10 | if 1:
|
10 | if 1:
|
||||||
| E271
|
| E271
|
||||||
11 | #: E273
|
11 | #: E273
|
||||||
12 | True and False
|
12 | True and False
|
||||||
|
|
|
|
||||||
|
|
||||||
E27.py:14:6: E271 Multiple spaces after keyword
|
E27.py:14:6: E271 Multiple spaces after keyword
|
||||||
|
|
|
|
||||||
14 | True and False
|
14 | True and False
|
||||||
15 | #: E271
|
15 | #: E271
|
||||||
16 | a and b
|
16 | a and b
|
||||||
| E271
|
| E271
|
||||||
|
|
|
@ -28,7 +28,7 @@ E27.py:24:5: E272 Multiple spaces before keyword
|
||||||
26 | this and False
|
26 | this and False
|
||||||
| E272
|
| E272
|
||||||
27 | #: E273
|
27 | #: E273
|
||||||
28 | a and b
|
28 | a and b
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,17 @@ E27.py:10:9: E273 Tab after keyword
|
||||||
|
|
|
|
||||||
10 | if 1:
|
10 | if 1:
|
||||||
11 | #: E273
|
11 | #: E273
|
||||||
12 | True and False
|
12 | True and False
|
||||||
| E273
|
| E273
|
||||||
13 | #: E273 E274
|
13 | #: E273 E274
|
||||||
14 | True and False
|
14 | True and False
|
||||||
|
|
|
|
||||||
|
|
||||||
E27.py:12:5: E273 Tab after keyword
|
E27.py:12:5: E273 Tab after keyword
|
||||||
|
|
|
|
||||||
12 | True and False
|
12 | True and False
|
||||||
13 | #: E273 E274
|
13 | #: E273 E274
|
||||||
14 | True and False
|
14 | True and False
|
||||||
| E273
|
| E273
|
||||||
15 | #: E271
|
15 | #: E271
|
||||||
16 | a and b
|
16 | a and b
|
||||||
|
@ -23,10 +23,10 @@ E27.py:12:5: E273 Tab after keyword
|
||||||
|
|
||||||
E27.py:12:10: E273 Tab after keyword
|
E27.py:12:10: E273 Tab after keyword
|
||||||
|
|
|
|
||||||
12 | True and False
|
12 | True and False
|
||||||
13 | #: E273 E274
|
13 | #: E273 E274
|
||||||
14 | True and False
|
14 | True and False
|
||||||
| E273
|
| E273
|
||||||
15 | #: E271
|
15 | #: E271
|
||||||
16 | a and b
|
16 | a and b
|
||||||
|
|
|
|
||||||
|
@ -35,18 +35,18 @@ E27.py:26:6: E273 Tab after keyword
|
||||||
|
|
|
|
||||||
26 | this and False
|
26 | this and False
|
||||||
27 | #: E273
|
27 | #: E273
|
||||||
28 | a and b
|
28 | a and b
|
||||||
| E273
|
| E273
|
||||||
29 | #: E274
|
29 | #: E274
|
||||||
30 | a and b
|
30 | a and b
|
||||||
|
|
|
|
||||||
|
|
||||||
E27.py:30:10: E273 Tab after keyword
|
E27.py:30:10: E273 Tab after keyword
|
||||||
|
|
|
|
||||||
30 | a and b
|
30 | a and b
|
||||||
31 | #: E273 E274
|
31 | #: E273 E274
|
||||||
32 | this and False
|
32 | this and False
|
||||||
| E273
|
| E273
|
||||||
33 | #: Okay
|
33 | #: Okay
|
||||||
34 | from u import (a, b)
|
34 | from u import (a, b)
|
||||||
|
|
|
|
||||||
|
|
|
@ -3,20 +3,20 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs
|
||||||
---
|
---
|
||||||
E27.py:28:3: E274 Tab before keyword
|
E27.py:28:3: E274 Tab before keyword
|
||||||
|
|
|
|
||||||
28 | a and b
|
28 | a and b
|
||||||
29 | #: E274
|
29 | #: E274
|
||||||
30 | a and b
|
30 | a and b
|
||||||
| E274
|
| E274
|
||||||
31 | #: E273 E274
|
31 | #: E273 E274
|
||||||
32 | this and False
|
32 | this and False
|
||||||
|
|
|
|
||||||
|
|
||||||
E27.py:30:6: E274 Tab before keyword
|
E27.py:30:6: E274 Tab before keyword
|
||||||
|
|
|
|
||||||
30 | a and b
|
30 | a and b
|
||||||
31 | #: E273 E274
|
31 | #: E273 E274
|
||||||
32 | this and False
|
32 | this and False
|
||||||
| E274
|
| E274
|
||||||
33 | #: Okay
|
33 | #: Okay
|
||||||
34 | from u import (a, b)
|
34 | from u import (a, b)
|
||||||
|
|
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ W19.py:3:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
3 | #: W191
|
3 | #: W191
|
||||||
4 | if False:
|
4 | if False:
|
||||||
5 | print # indented with 1 tab
|
5 | print # indented with 1 tab
|
||||||
| W191
|
| ^^^^ W191
|
||||||
6 | #:
|
6 | #:
|
||||||
|
|
|
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ W19.py:9:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
9 | #: W191
|
9 | #: W191
|
||||||
10 | y = x == 2 \
|
10 | y = x == 2 \
|
||||||
11 | or x == 3
|
11 | or x == 3
|
||||||
| W191
|
| ^^^^ W191
|
||||||
12 | #: E101 W191 W504
|
12 | #: E101 W191 W504
|
||||||
13 | if (
|
13 | if (
|
||||||
|
|
|
|
||||||
|
@ -24,8 +24,8 @@ W19.py:16:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
16 | ) or
|
16 | ) or
|
||||||
17 | y == 4):
|
17 | y == 4):
|
||||||
18 | pass
|
18 | pass
|
||||||
| W191
|
| ^^^^ W191
|
||||||
19 | #: E101 W191
|
19 | #: E101 W191
|
||||||
20 | if x == 2 \
|
20 | if x == 2 \
|
||||||
|
|
|
|
||||||
|
@ -34,8 +34,8 @@ W19.py:21:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
21 | or y > 1 \
|
21 | or y > 1 \
|
||||||
22 | or x == 3:
|
22 | or x == 3:
|
||||||
23 | pass
|
23 | pass
|
||||||
| W191
|
| ^^^^ W191
|
||||||
24 | #: E101 W191
|
24 | #: E101 W191
|
||||||
25 | if x == 2 \
|
25 | if x == 2 \
|
||||||
|
|
|
|
||||||
|
@ -44,8 +44,8 @@ W19.py:26:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
26 | or y > 1 \
|
26 | or y > 1 \
|
||||||
27 | or x == 3:
|
27 | or x == 3:
|
||||||
28 | pass
|
28 | pass
|
||||||
| W191
|
| ^^^^ W191
|
||||||
29 | #:
|
29 | #:
|
||||||
|
|
|
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ W19.py:32:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
32 | if (foo == bar and
|
32 | if (foo == bar and
|
||||||
33 | baz == bop):
|
33 | baz == bop):
|
||||||
34 | pass
|
34 | pass
|
||||||
| W191
|
| ^^^^ W191
|
||||||
35 | #: E101 W191 W504
|
35 | #: E101 W191 W504
|
||||||
36 | if (
|
36 | if (
|
||||||
|
|
|
|
||||||
|
@ -63,8 +63,8 @@ W19.py:38:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
38 | baz == bop
|
38 | baz == bop
|
||||||
39 | ):
|
39 | ):
|
||||||
40 | pass
|
40 | pass
|
||||||
| W191
|
| ^^^^ W191
|
||||||
41 | #:
|
41 | #:
|
||||||
|
|
|
|
||||||
|
|
||||||
|
@ -72,18 +72,18 @@ W19.py:44:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
44 | if start[1] > end_col and not (
|
44 | if start[1] > end_col and not (
|
||||||
45 | over_indent == 4 and indent_next):
|
45 | over_indent == 4 and indent_next):
|
||||||
46 | return (0, "E121 continuation line over-"
|
46 | return (0, "E121 continuation line over-"
|
||||||
| W191
|
| ^^^^ W191
|
||||||
47 | "indented for visual indent")
|
47 | "indented for visual indent")
|
||||||
48 | #:
|
48 | #:
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:45:1: W191 Indentation contains tabs
|
W19.py:45:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
45 | over_indent == 4 and indent_next):
|
45 | over_indent == 4 and indent_next):
|
||||||
46 | return (0, "E121 continuation line over-"
|
46 | return (0, "E121 continuation line over-"
|
||||||
47 | "indented for visual indent")
|
47 | "indented for visual indent")
|
||||||
| ^^^^^^^^ W191
|
| ^^^^^^^^^^^^ W191
|
||||||
48 | #:
|
48 | #:
|
||||||
|
|
|
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ W19.py:54:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
54 | var_one, var_two, var_three,
|
54 | var_one, var_two, var_three,
|
||||||
55 | var_four):
|
55 | var_four):
|
||||||
56 | print(var_one)
|
56 | print(var_one)
|
||||||
| W191
|
| ^^^^ W191
|
||||||
57 | #: E101 W191 W504
|
57 | #: E101 W191 W504
|
||||||
58 | if ((row < 0 or self.moduleCount <= row or
|
58 | if ((row < 0 or self.moduleCount <= row or
|
||||||
|
|
|
|
||||||
|
@ -101,8 +101,8 @@ W19.py:58:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
58 | if ((row < 0 or self.moduleCount <= row or
|
58 | if ((row < 0 or self.moduleCount <= row or
|
||||||
59 | col < 0 or self.moduleCount <= col)):
|
59 | col < 0 or self.moduleCount <= col)):
|
||||||
60 | raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
|
60 | raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
|
||||||
| W191
|
| ^^^^ W191
|
||||||
61 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
|
61 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
|
||||||
62 | if bar:
|
62 | if bar:
|
||||||
|
|
|
|
||||||
|
@ -111,58 +111,58 @@ W19.py:61:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
61 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
|
61 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
|
||||||
62 | if bar:
|
62 | if bar:
|
||||||
63 | return (
|
63 | return (
|
||||||
| W191
|
| ^^^^ W191
|
||||||
64 | start, 'E121 lines starting with a '
|
64 | start, 'E121 lines starting with a '
|
||||||
65 | 'closing bracket should be indented '
|
65 | 'closing bracket should be indented '
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:62:1: W191 Indentation contains tabs
|
W19.py:62:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
62 | if bar:
|
62 | if bar:
|
||||||
63 | return (
|
63 | return (
|
||||||
64 | start, 'E121 lines starting with a '
|
64 | start, 'E121 lines starting with a '
|
||||||
| ^^^^ W191
|
| ^^^^^^^^ W191
|
||||||
65 | 'closing bracket should be indented '
|
65 | 'closing bracket should be indented '
|
||||||
66 | "to match that of the opening "
|
66 | "to match that of the opening "
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:63:1: W191 Indentation contains tabs
|
W19.py:63:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
63 | return (
|
63 | return (
|
||||||
64 | start, 'E121 lines starting with a '
|
64 | start, 'E121 lines starting with a '
|
||||||
65 | 'closing bracket should be indented '
|
65 | 'closing bracket should be indented '
|
||||||
| ^^^^ W191
|
| ^^^^^^^^ W191
|
||||||
66 | "to match that of the opening "
|
66 | "to match that of the opening "
|
||||||
67 | "bracket's line"
|
67 | "bracket's line"
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:64:1: W191 Indentation contains tabs
|
W19.py:64:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
64 | start, 'E121 lines starting with a '
|
64 | start, 'E121 lines starting with a '
|
||||||
65 | 'closing bracket should be indented '
|
65 | 'closing bracket should be indented '
|
||||||
66 | "to match that of the opening "
|
66 | "to match that of the opening "
|
||||||
| ^^^^ W191
|
| ^^^^^^^^ W191
|
||||||
67 | "bracket's line"
|
67 | "bracket's line"
|
||||||
68 | )
|
68 | )
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:65:1: W191 Indentation contains tabs
|
W19.py:65:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
65 | 'closing bracket should be indented '
|
65 | 'closing bracket should be indented '
|
||||||
66 | "to match that of the opening "
|
66 | "to match that of the opening "
|
||||||
67 | "bracket's line"
|
67 | "bracket's line"
|
||||||
| ^^^^ W191
|
| ^^^^^^^^ W191
|
||||||
68 | )
|
68 | )
|
||||||
69 | #
|
69 | #
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:66:1: W191 Indentation contains tabs
|
W19.py:66:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
66 | "to match that of the opening "
|
66 | "to match that of the opening "
|
||||||
67 | "bracket's line"
|
67 | "bracket's line"
|
||||||
68 | )
|
68 | )
|
||||||
| W191
|
| ^^^^ W191
|
||||||
69 | #
|
69 | #
|
||||||
70 | #: E101 W191 W504
|
70 | #: E101 W191 W504
|
||||||
|
|
|
|
||||||
|
@ -171,8 +171,8 @@ W19.py:73:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
73 | foo.bar("bop")
|
73 | foo.bar("bop")
|
||||||
74 | )):
|
74 | )):
|
||||||
75 | print "yes"
|
75 | print "yes"
|
||||||
| W191
|
| ^^^^ W191
|
||||||
76 | #: E101 W191 W504
|
76 | #: E101 W191 W504
|
||||||
77 | # also ok, but starting to look like LISP
|
77 | # also ok, but starting to look like LISP
|
||||||
|
|
|
|
||||||
|
@ -181,8 +181,8 @@ W19.py:78:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
78 | if ((foo.bar("baz") and
|
78 | if ((foo.bar("baz") and
|
||||||
79 | foo.bar("bop"))):
|
79 | foo.bar("bop"))):
|
||||||
80 | print "yes"
|
80 | print "yes"
|
||||||
| W191
|
| ^^^^ W191
|
||||||
81 | #: E101 W191 W504
|
81 | #: E101 W191 W504
|
||||||
82 | if (a == 2 or
|
82 | if (a == 2 or
|
||||||
|
|
|
|
||||||
|
@ -191,8 +191,8 @@ W19.py:83:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
83 | b == "abc def ghi"
|
83 | b == "abc def ghi"
|
||||||
84 | "jkl mno"):
|
84 | "jkl mno"):
|
||||||
85 | return True
|
85 | return True
|
||||||
| W191
|
| ^^^^ W191
|
||||||
86 | #: E101 W191 W504
|
86 | #: E101 W191 W504
|
||||||
87 | if (a == 2 or
|
87 | if (a == 2 or
|
||||||
|
|
|
|
||||||
|
@ -201,8 +201,8 @@ W19.py:88:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
88 | b == """abc def ghi
|
88 | b == """abc def ghi
|
||||||
89 | jkl mno"""):
|
89 | jkl mno"""):
|
||||||
90 | return True
|
90 | return True
|
||||||
| W191
|
| ^^^^ W191
|
||||||
91 | #: W191:2:1 W191:3:1 E101:3:2
|
91 | #: W191:2:1 W191:3:1 E101:3:2
|
||||||
92 | if length > options.max_line_length:
|
92 | if length > options.max_line_length:
|
||||||
|
|
|
|
||||||
|
@ -211,35 +211,35 @@ W19.py:91:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
91 | #: W191:2:1 W191:3:1 E101:3:2
|
91 | #: W191:2:1 W191:3:1 E101:3:2
|
||||||
92 | if length > options.max_line_length:
|
92 | if length > options.max_line_length:
|
||||||
93 | return options.max_line_length, \
|
93 | return options.max_line_length, \
|
||||||
| W191
|
| ^^^^ W191
|
||||||
94 | "E501 line too long (%d characters)" % length
|
94 | "E501 line too long (%d characters)" % length
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:92:1: W191 Indentation contains tabs
|
W19.py:92:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
92 | if length > options.max_line_length:
|
92 | if length > options.max_line_length:
|
||||||
93 | return options.max_line_length, \
|
93 | return options.max_line_length, \
|
||||||
94 | "E501 line too long (%d characters)" % length
|
94 | "E501 line too long (%d characters)" % length
|
||||||
| ^^^^ W191
|
| ^^^^^^^^ W191
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:98:1: W191 Indentation contains tabs
|
W19.py:98:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
98 | #: E101 W191 W191 W504
|
98 | #: E101 W191 W191 W504
|
||||||
99 | if os.path.exists(os.path.join(path, PEP8_BIN)):
|
99 | if os.path.exists(os.path.join(path, PEP8_BIN)):
|
||||||
100 | cmd = ([os.path.join(path, PEP8_BIN)] +
|
100 | cmd = ([os.path.join(path, PEP8_BIN)] +
|
||||||
| W191
|
| ^^^^ W191
|
||||||
101 | self._pep8_options(targetfile))
|
101 | self._pep8_options(targetfile))
|
||||||
102 | #: W191 - okay
|
102 | #: W191 - okay
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:99:1: W191 Indentation contains tabs
|
W19.py:99:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
99 | if os.path.exists(os.path.join(path, PEP8_BIN)):
|
99 | if os.path.exists(os.path.join(path, PEP8_BIN)):
|
||||||
100 | cmd = ([os.path.join(path, PEP8_BIN)] +
|
100 | cmd = ([os.path.join(path, PEP8_BIN)] +
|
||||||
101 | self._pep8_options(targetfile))
|
101 | self._pep8_options(targetfile))
|
||||||
| ^^^^^^^ W191
|
| ^^^^^^^^^^^ W191
|
||||||
102 | #: W191 - okay
|
102 | #: W191 - okay
|
||||||
103 | '''
|
103 | '''
|
||||||
|
|
|
|
||||||
|
@ -248,36 +248,36 @@ W19.py:125:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
125 | if foo is None and bar is "bop" and \
|
125 | if foo is None and bar is "bop" and \
|
||||||
126 | blah == 'yeah':
|
126 | blah == 'yeah':
|
||||||
127 | blah = 'yeahnah'
|
127 | blah = 'yeahnah'
|
||||||
| W191
|
| ^^^^ W191
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:131:1: W191 Indentation contains tabs
|
W19.py:131:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
131 | #: W191 W191 W191
|
131 | #: W191 W191 W191
|
||||||
132 | if True:
|
132 | if True:
|
||||||
133 | foo(
|
133 | foo(
|
||||||
| W191
|
| ^^^^ W191
|
||||||
134 | 1,
|
134 | 1,
|
||||||
135 | 2)
|
135 | 2)
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:132:1: W191 Indentation contains tabs
|
W19.py:132:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
132 | if True:
|
132 | if True:
|
||||||
133 | foo(
|
133 | foo(
|
||||||
134 | 1,
|
134 | 1,
|
||||||
| W191
|
| ^^^^^^^^ W191
|
||||||
135 | 2)
|
135 | 2)
|
||||||
136 | #: W191 W191 W191 W191 W191
|
136 | #: W191 W191 W191 W191 W191
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:133:1: W191 Indentation contains tabs
|
W19.py:133:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
133 | foo(
|
133 | foo(
|
||||||
134 | 1,
|
134 | 1,
|
||||||
135 | 2)
|
135 | 2)
|
||||||
| W191
|
| ^^^^^^^^ W191
|
||||||
136 | #: W191 W191 W191 W191 W191
|
136 | #: W191 W191 W191 W191 W191
|
||||||
137 | def test_keys(self):
|
137 | def test_keys(self):
|
||||||
|
|
|
|
||||||
|
@ -286,48 +286,48 @@ W19.py:136:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
136 | #: W191 W191 W191 W191 W191
|
136 | #: W191 W191 W191 W191 W191
|
||||||
137 | def test_keys(self):
|
137 | def test_keys(self):
|
||||||
138 | """areas.json - All regions are accounted for."""
|
138 | """areas.json - All regions are accounted for."""
|
||||||
| W191
|
| ^^^^ W191
|
||||||
139 | expected = set([
|
139 | expected = set([
|
||||||
140 | u'Norrbotten',
|
140 | u'Norrbotten',
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:137:1: W191 Indentation contains tabs
|
W19.py:137:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
137 | def test_keys(self):
|
137 | def test_keys(self):
|
||||||
138 | """areas.json - All regions are accounted for."""
|
138 | """areas.json - All regions are accounted for."""
|
||||||
139 | expected = set([
|
139 | expected = set([
|
||||||
| W191
|
| ^^^^ W191
|
||||||
140 | u'Norrbotten',
|
140 | u'Norrbotten',
|
||||||
141 | u'V\xe4sterbotten',
|
141 | u'V\xe4sterbotten',
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:138:1: W191 Indentation contains tabs
|
W19.py:138:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
138 | """areas.json - All regions are accounted for."""
|
138 | """areas.json - All regions are accounted for."""
|
||||||
139 | expected = set([
|
139 | expected = set([
|
||||||
140 | u'Norrbotten',
|
140 | u'Norrbotten',
|
||||||
| W191
|
| ^^^^^^^^ W191
|
||||||
141 | u'V\xe4sterbotten',
|
141 | u'V\xe4sterbotten',
|
||||||
142 | ])
|
142 | ])
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:139:1: W191 Indentation contains tabs
|
W19.py:139:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
139 | expected = set([
|
139 | expected = set([
|
||||||
140 | u'Norrbotten',
|
140 | u'Norrbotten',
|
||||||
141 | u'V\xe4sterbotten',
|
141 | u'V\xe4sterbotten',
|
||||||
| W191
|
| ^^^^^^^^ W191
|
||||||
142 | ])
|
142 | ])
|
||||||
143 | #: W191
|
143 | #: W191
|
||||||
|
|
|
|
||||||
|
|
||||||
W19.py:140:1: W191 Indentation contains tabs
|
W19.py:140:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
140 | u'Norrbotten',
|
140 | u'Norrbotten',
|
||||||
141 | u'V\xe4sterbotten',
|
141 | u'V\xe4sterbotten',
|
||||||
142 | ])
|
142 | ])
|
||||||
| W191
|
| ^^^^ W191
|
||||||
143 | #: W191
|
143 | #: W191
|
||||||
144 | x = [
|
144 | x = [
|
||||||
|
|
|
|
||||||
|
@ -336,8 +336,8 @@ W19.py:143:1: W191 Indentation contains tabs
|
||||||
|
|
|
|
||||||
143 | #: W191
|
143 | #: W191
|
||||||
144 | x = [
|
144 | x = [
|
||||||
145 | 'abc'
|
145 | 'abc'
|
||||||
| W191
|
| ^^^^ W191
|
||||||
146 | ]
|
146 | ]
|
||||||
147 | #: W191 - okay
|
147 | #: W191 - okay
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue