Skip to content

Commit c066b4f

Browse files
committed
change default indent from 2 to 4
1 parent f24fa21 commit c066b4f

4 files changed

Lines changed: 67 additions & 67 deletions

File tree

devtools/debug.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def str(self, colour=False, highlight=False) -> str:
4242
s = ''
4343
if self.name:
4444
s = sformat(self.name, sformat.blue, apply=colour) + ': '
45-
s += pformat(self.value, indent=2, highlight=highlight)
45+
s += pformat(self.value, indent=4, highlight=highlight)
4646
suffix = (
4747
' ({0.value.__class__.__name__}) {1}'
4848
.format(self, ' '.join('{}={}'.format(k, v) for k, v in self.extra))
@@ -70,14 +70,14 @@ def __init__(self, *, filename: str, lineno: int, frame: str, arguments: List[De
7070

7171
def str(self, colour=False, highlight=False) -> str:
7272
if colour:
73-
prefix = '{}:{} {}\n '.format(
73+
prefix = '{}:{} {}'.format(
7474
sformat(self.filename, sformat.magenta),
7575
sformat(self.lineno, sformat.green),
7676
sformat(self.frame, sformat.green, sformat.italic)
7777
)
7878
else:
79-
prefix = '{0.filename}:{0.lineno} {0.frame}\n '.format(self)
80-
return prefix + '\n '.join(a.str(colour, highlight) for a in self.arguments)
79+
prefix = '{0.filename}:{0.lineno} {0.frame}'.format(self)
80+
return prefix + '\n ' + '\n '.join(a.str(colour, highlight) for a in self.arguments)
8181

8282
def __str__(self) -> str:
8383
return self.str()

devtools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__all__ = ['VERSION']
44

5-
VERSION = StrictVersion('0.1.1')
5+
VERSION = StrictVersion('0.2.0')

tests/test_expr_render.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_simple():
1717
# print(s)
1818
assert (
1919
'tests/test_expr_render.py:<line no> test_simple\n'
20-
' len(a): 3 (int)'
20+
' len(a): 3 (int)'
2121
) == s
2222

2323

@@ -41,24 +41,24 @@ def test_exotic_types():
4141
# list and generator comprehensions are wrong because ast is wrong, see https://bugs.python.org/issue31241
4242
assert (
4343
"tests/test_expr_render.py:<line no> test_exotic_types\n"
44-
" sum(aa): 6 (int)\n"
45-
" 1 == 2: False (bool)\n"
46-
" 1 < 2: True (bool)\n"
47-
" 1 << 2: 4 (int)\n"
48-
" 't' if True else 'f': 't' (str) len=1\n"
49-
" 1 or 2: 1 (int)\n"
50-
" [a for a in aa]: [1, 2, 3] (list)\n"
51-
" {a for a in aa}: {1, 2, 3} (set)\n"
52-
" {a: a + 1 for a in aa}: {\n"
53-
" 1: 2,\n"
54-
" 2: 3,\n"
55-
" 3: 4,\n"
56-
" } (dict)\n"
57-
" (a for a in aa): (\n"
58-
" 1,\n"
59-
" 2,\n"
60-
" 3,\n"
61-
" ) (generator)"
44+
" sum(aa): 6 (int)\n"
45+
" 1 == 2: False (bool)\n"
46+
" 1 < 2: True (bool)\n"
47+
" 1 << 2: 4 (int)\n"
48+
" 't' if True else 'f': 't' (str) len=1\n"
49+
" 1 or 2: 1 (int)\n"
50+
" [a for a in aa]: [1, 2, 3] (list)\n"
51+
" {a for a in aa}: {1, 2, 3} (set)\n"
52+
" {a: a + 1 for a in aa}: {\n"
53+
" 1: 2,\n"
54+
" 2: 3,\n"
55+
" 3: 4,\n"
56+
" } (dict)\n"
57+
" (a for a in aa): (\n"
58+
" 1,\n"
59+
" 2,\n"
60+
" 3,\n"
61+
" ) (generator)"
6262
) == s
6363

6464

@@ -69,7 +69,7 @@ def test_newline():
6969
# print(s)
7070
assert (
7171
'tests/test_expr_render.py:<line no> test_newline\n'
72-
' foobar(1, 2, 3): 6 (int)'
72+
' foobar(1, 2, 3): 6 (int)'
7373
) == s
7474

7575

@@ -81,7 +81,7 @@ def test_trailing_bracket():
8181
# print(s)
8282
assert (
8383
'tests/test_expr_render.py:<line no> test_trailing_bracket\n'
84-
' foobar(1, 2, 3): 6 (int)'
84+
' foobar(1, 2, 3): 6 (int)'
8585
) == s
8686

8787

@@ -95,7 +95,7 @@ def test_multiline():
9595
# print(s)
9696
assert (
9797
'tests/test_expr_render.py:<line no> test_multiline\n'
98-
' foobar(1, 2, 3): 6 (int)'
98+
' foobar(1, 2, 3): 6 (int)'
9999
) == s
100100

101101

@@ -107,7 +107,7 @@ def test_multiline_trailing_bracket():
107107
# print(s)
108108
assert (
109109
'tests/test_expr_render.py:<line no> test_multiline_trailing_bracket\n'
110-
' foobar(1, 2, 3 ): 6 (int)'
110+
' foobar(1, 2, 3 ): 6 (int)'
111111
) == s
112112

113113

@@ -121,9 +121,9 @@ def test_kwargs():
121121
s = re.sub(':\d{2,}', ':<line no>', str(v))
122122
assert (
123123
'tests/test_expr_render.py:<line no> test_kwargs\n'
124-
' foobar(1, 2, 3): 6 (int)\n'
125-
' a: 6 (int)\n'
126-
' b: 7 (int)'
124+
' foobar(1, 2, 3): 6 (int)\n'
125+
' a: 6 (int)\n'
126+
' b: 7 (int)'
127127
) == s
128128

129129

@@ -138,9 +138,9 @@ def test_kwargs_multiline():
138138
s = re.sub(':\d{2,}', ':<line no>', str(v))
139139
assert (
140140
'tests/test_expr_render.py:<line no> test_kwargs_multiline\n'
141-
' foobar(1, 2, 3): 6 (int)\n'
142-
' a: 6 (int)\n'
143-
' b: 7 (int)'
141+
' foobar(1, 2, 3): 6 (int)\n'
142+
' a: 6 (int)\n'
143+
' b: 7 (int)'
144144
) == s
145145

146146

@@ -152,7 +152,7 @@ def test_multiple_trailing_lines():
152152
)
153153
s = re.sub(':\d{2,}', ':<line no>', str(v))
154154
assert (
155-
'tests/test_expr_render.py:<line no> test_multiple_trailing_lines\n foobar( 1, 2, 3 ): 6 (int)'
155+
'tests/test_expr_render.py:<line no> test_multiple_trailing_lines\n foobar( 1, 2, 3 ): 6 (int)'
156156
) == s
157157

158158

@@ -178,7 +178,7 @@ def test_syntax_warning():
178178
assert '-1\n"' in str(warning.message)
179179
s = re.sub(':\d{2,}', ':<line no>', str(v))
180180
assert (
181-
'tests/test_expr_render.py:<line no> test_syntax_warning\n 1 (int)'
181+
'tests/test_expr_render.py:<line no> test_syntax_warning\n 1 (int)'
182182
) == s
183183

184184

@@ -197,5 +197,5 @@ def test_no_syntax_warning():
197197
)
198198
)
199199
)
200-
assert 'test_no_syntax_warning\n 1 (int)' in str(v)
200+
assert 'test_no_syntax_warning\n 1 (int)' in str(v)
201201
assert len(warning_checker) == 0

tests/test_main.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def test_print(capsys):
1717
print(stdout)
1818
assert re.sub(':\d{2,}', ':<line no>', stdout) == (
1919
'tests/test_main.py:<line no> test_print\n'
20-
' a: 1 (int)\n'
21-
' b: 2 (int)\n'
20+
' a: 1 (int)\n'
21+
' b: 2 (int)\n'
2222
)
2323
assert stderr == ''
2424

@@ -31,8 +31,8 @@ def test_format():
3131
print(repr(s))
3232
assert s == (
3333
"tests/test_main.py:<line no> test_format\n"
34-
" a: b'i might bite' (bytes) len=12\n"
35-
" b: 'hello this is a test' (str) len=20"
34+
" a: b'i might bite' (bytes) len=12\n"
35+
" b: 'hello this is a test' (str) len=20"
3636
)
3737

3838

@@ -57,10 +57,10 @@ def test_func(v):
5757
assert p.stdout.replace(str(f), '/path/to/test.py') == (
5858
"running debug...\n"
5959
"/path/to/test.py:8 <module>\n"
60-
" foobar: 'hello world' (str) len=11\n"
60+
" foobar: 'hello world' (str) len=11\n"
6161
"/path/to/test.py:4 test_func\n"
62-
" 'in test func' (str) len=12\n"
63-
" v: 42 (int)\n"
62+
" 'in test func' (str) len=12\n"
63+
" v: 42 (int)\n"
6464
"debug run.\n"
6565
)
6666

@@ -70,7 +70,7 @@ def test_odd_path(mocker):
7070
mocked_relative_to = mocker.patch('pathlib.Path.relative_to')
7171
mocked_relative_to.side_effect = ValueError()
7272
v = debug.format('test')
73-
assert re.search("/.*?/test_main.py:\d{2,} test_odd_path\n 'test' \(str\) len=4", str(v)), v
73+
assert re.search("/.*?/test_main.py:\d{2,} test_odd_path\n 'test' \(str\) len=4", str(v)), v
7474

7575

7676
def test_small_call_frame():
@@ -82,9 +82,9 @@ def test_small_call_frame():
8282
)
8383
assert re.sub(':\d{2,}', ':<line no>', str(v)) == (
8484
'tests/test_main.py:<line no> test_small_call_frame\n'
85-
' 1 (int)\n'
86-
' 2 (int)\n'
87-
' 3 (int)'
85+
' 1 (int)\n'
86+
' 2 (int)\n'
87+
' 3 (int)'
8888
)
8989

9090

@@ -98,9 +98,9 @@ def test_small_call_frame_warning():
9898
)
9999
assert re.sub(':\d{2,}', ':<line no>', str(v)) == (
100100
'tests/test_main.py:<line no> test_small_call_frame_warning\n'
101-
' 1 (int)\n'
102-
' 2 (int)\n'
103-
' 3 (int)'
101+
' 1 (int)\n'
102+
' 2 (int)\n'
103+
' 3 (int)'
104104
)
105105

106106

@@ -112,8 +112,8 @@ def test_kwargs():
112112
print(s)
113113
assert s == (
114114
"tests/test_main.py:<line no> test_kwargs\n"
115-
" first: 'variable' (str) len=8 variable=a\n"
116-
" second: 'literal' (str) len=7"
115+
" first: 'variable' (str) len=8 variable=a\n"
116+
" second: 'literal' (str) len=7"
117117
)
118118

119119

@@ -124,8 +124,8 @@ def test_kwargs_orderless():
124124
s = re.sub(':\d{2,}', ':<line no>', str(v))
125125
assert set(s.split('\n')) == {
126126
"tests/test_main.py:<line no> test_kwargs_orderless",
127-
" first: 'variable' (str) len=8 variable=a",
128-
" second: 'literal' (str) len=7",
127+
" first: 'variable' (str) len=8 variable=a",
128+
" second: 'literal' (str) len=7",
129129
}
130130

131131

@@ -134,9 +134,9 @@ def test_simple_vars():
134134
s = re.sub(':\d{2,}', ':<line no>', str(v))
135135
assert s == (
136136
"tests/test_main.py:<line no> test_simple_vars\n"
137-
" 'test' (str) len=4\n"
138-
" 1 (int)\n"
139-
" 2 (int)"
137+
" 'test' (str) len=4\n"
138+
" 1 (int)\n"
139+
" 2 (int)"
140140
)
141141
r = re.sub(':\d{2,}', ':<line no>', repr(v))
142142
assert r == (
@@ -153,23 +153,23 @@ class Bar:
153153

154154
b = Bar()
155155
v = debug.format(b.y.x)
156-
assert 'test_attributes\n b.y.x: 1 (int)' in str(v)
156+
assert 'test_attributes\n b.y.x: 1 (int)' in str(v)
157157

158158

159159
def test_eval():
160160
with pytest.warns(RuntimeWarning):
161161
v = eval('debug.format(1)')
162162

163-
assert str(v) == '<string>:1 <module>\n 1 (int)'
163+
assert str(v) == '<string>:1 <module>\n 1 (int)'
164164

165165

166166
def test_warnings_disabled():
167167
debug_ = Debug(warnings=False)
168168
with pytest.warns(None) as warnings:
169169
v1 = eval('debug_.format(1)')
170-
assert str(v1) == '<string>:1 <module>\n 1 (int)'
170+
assert str(v1) == '<string>:1 <module>\n 1 (int)'
171171
v2 = debug_.format(1)
172-
assert 'test_warnings_disabled\n 1 (int)' in str(v2)
172+
assert 'test_warnings_disabled\n 1 (int)' in str(v2)
173173
assert len(warnings) == 0
174174

175175

@@ -180,8 +180,8 @@ def test_eval_kwargs():
180180

181181
assert str(v) == (
182182
"<string>:1 <module>\n"
183-
" 1 (int)\n"
184-
" apple: 'pear' (str) len=4"
183+
" 1 (int)\n"
184+
" apple: 'pear' (str) len=4"
185185
)
186186

187187

@@ -196,8 +196,8 @@ def test_exec(capsys):
196196
stdout, stderr = capsys.readouterr()
197197
assert stdout == (
198198
'<string>:3 <module>\n'
199-
' 2 (int)\n'
200-
' 3 (int)\n'
199+
' 2 (int)\n'
200+
' 3 (int)\n'
201201
)
202202
assert stderr == ''
203203

@@ -215,7 +215,7 @@ def test_inspect_error(mocker):
215215
mocked_getouterframes.side_effect = IndexError()
216216
with pytest.warns(SyntaxWarning):
217217
v = debug.format('x')
218-
assert str(v) == "<unknown>:0 \n 'x' (str) len=1"
218+
assert str(v) == "<unknown>:0 \n 'x' (str) len=1"
219219

220220

221221
def test_breakpoint(mocker):

0 commit comments

Comments
 (0)