1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
Before:
Save g:ale_warn_about_trailing_whitespace
let g:ale_warn_about_trailing_whitespace = 1
runtime ale_linters/python/pylama.vim
After:
Restore
call ale#linter#Reset()
silent file something_else.py
Execute(The pylama handler should handle no messages with version older than 8.1.4):
AssertEqual [], ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [])
Execute(The pylama handler should handle no messages with version newer or equal than 8.1.4):
AssertEqual [], ale_linters#python#pylama#Handle(bufnr(''), [8, 2, 0], [])
Execute(The pylama handler should handle basic warnings and syntax errors with version older than 8.1.4):
AssertEqual
\ [
\ {
\ 'lnum': 8,
\ 'col': 1,
\ 'code': 'W0611',
\ 'type': 'W',
\ 'sub_type': '',
\ 'text': '''foo'' imported but unused [pyflakes]',
\ },
\ {
\ 'lnum': 8,
\ 'col': 0,
\ 'code': 'E0401',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'Unable to import ''foo'' [pylint]',
\ },
\ {
\ 'lnum': 10,
\ 'col': 1,
\ 'code': 'E302',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'expected 2 blank lines, found 1 [pycodestyle]',
\ },
\ {
\ 'lnum': 11,
\ 'col': 1,
\ 'code': 'D401',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
\ },
\ {
\ 'lnum': 15,
\ 'col': 81,
\ 'code': 'E501',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'line too long (96 > 80 characters) [pycodestyle]',
\ },
\ {
\ 'lnum': 16,
\ 'col': 1,
\ 'code': 'D203',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': '1 blank line required before class docstring (found 0) [pydocstyle]',
\ },
\ {
\ 'lnum': 18,
\ 'col': 1,
\ 'code': 'D107',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'Missing docstring in __init__ [pydocstyle]',
\ },
\ {
\ 'lnum': 20,
\ 'col': 0,
\ 'code': 'C4001',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'Invalid string quote ", should be '' [pylint]',
\ },
\ ],
\ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
\ 'No config file found, using default configuration',
\ 'index.py:8:1: W0611 ''foo'' imported but unused [pyflakes]',
\ 'index.py:8:0: E0401 Unable to import ''foo'' [pylint]',
\ 'index.py:10:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
\ 'index.py:11:1: D401 First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
\ 'index.py:15:81: E501 line too long (96 > 80 characters) [pycodestyle]',
\ 'index.py:16:1: D203 1 blank line required before class docstring (found 0) [pydocstyle]',
\ 'index.py:18:1: D107 Missing docstring in __init__ [pydocstyle]',
\ 'index.py:20:0: C4001 Invalid string quote ", should be '' [pylint]',
\ ])
Execute(The pylama handler should handle basic warnings and syntax errors with version newer than 8.1.4):
AssertEqual
\ [
\ {
\ 'lnum': 8,
\ 'col': 1,
\ 'code': 'W0611',
\ 'type': 'W',
\ 'sub_type': '',
\ 'text': '''foo'' imported but unused [pyflakes]',
\ },
\ {
\ 'lnum': 8,
\ 'col': 0,
\ 'code': 'E0401',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'Unable to import ''foo'' [pylint]',
\ },
\ {
\ 'lnum': 10,
\ 'col': 1,
\ 'code': 'E302',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'expected 2 blank lines, found 1 [pycodestyle]',
\ },
\ {
\ 'lnum': 11,
\ 'col': 1,
\ 'code': 'D401',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
\ },
\ {
\ 'lnum': 15,
\ 'col': 81,
\ 'code': 'E501',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'line too long (96 > 80 characters) [pycodestyle]',
\ },
\ {
\ 'lnum': 16,
\ 'col': 1,
\ 'code': 'D203',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': '1 blank line required before class docstring (found 0) [pydocstyle]',
\ },
\ {
\ 'lnum': 18,
\ 'col': 1,
\ 'code': 'D107',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'Missing docstring in __init__ [pydocstyle]',
\ },
\ {
\ 'lnum': 20,
\ 'col': 0,
\ 'code': 'C4001',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'Invalid string quote ", should be '' [pylint]',
\ },
\ ],
\ ale_linters#python#pylama#Handle(bufnr(''), [8, 2, 0], [
\ '[{"source":"pyflakes","col":1,"lnum":8,"etype":"W","message":"''foo'' imported but unused","filename":"index.py","number":"W0611"},{"source":"pylint","col":0,"lnum":8,"etype":"E","message":"Unable to import ''foo''","filename":"index.py","number":"E0401"},{"source":"pycodestyle","col":1,"lnum":10,"etype":"E","message":"expected 2 blank lines, found 1","filename":"index.py","number":"E302"},{"source":"pydocstyle","col":1,"lnum":11,"etype":"D","message":"First line should be in imperative mood (''Get'', not ''Gets'')","filename":"index.py","number":"D401"},{"source":"pycodestyle","col":81,"lnum":15,"etype":"E","message":"line too long (96 > 80 characters)","filename":"index.py","number":"E501"},{"source":"pydocstyle","col":1,"lnum":16,"etype":"D","message":"1 blank line required before class docstring (found 0)","filename":"index.py","number":"D203"},{"source":"pydocstyle","col":1,"lnum":18,"etype":"D","message":"Missing docstring in __init__","filename":"index.py","number":"D107"},{"source":"pylint","col":0,"lnum":20,"etype":"C","message":"Invalid string quote \", should be ''","filename":"index.py","number":"C4001"}]',
\ ])
Execute(The pylama handler should handle tracebacks with parsable messages with version older than 8.1.4):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'text': 'ParseError: Cannot parse file. (See :ALEDetail)',
\ 'detail': join([
\ 'Traceback (most recent call last):',
\ ' File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
\ ' path, code=code, ignore=ignore, select=select, params=lparams)',
\ ' File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
\ ' } for e in PyDocChecker().check_source(*check_source_args)]',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
\ ' module = parse(StringIO(source), filename)',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
\ ' return self.parse(*args, **kwargs)',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
\ ' six.raise_from(ParseError(), error)',
\ ' File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
\ ' raise value',
\ 'ParseError: Cannot parse file.',
\ ], "\n"),
\ },
\ {
\ 'lnum': 11,
\ 'col': 1,
\ 'code': 'E302',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'expected 2 blank lines, found 1 [pycodestyle]',
\ },
\ {
\ 'lnum': 16,
\ 'col': 81,
\ 'code': 'E501',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'line too long (96 > 80 characters) [pycodestyle]',
\ },
\ ],
\ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
\ 'Traceback (most recent call last):',
\ ' File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
\ ' path, code=code, ignore=ignore, select=select, params=lparams)',
\ ' File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
\ ' } for e in PyDocChecker().check_source(*check_source_args)]',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
\ ' module = parse(StringIO(source), filename)',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
\ ' return self.parse(*args, **kwargs)',
\ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
\ ' six.raise_from(ParseError(), error)',
\ ' File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
\ ' raise value',
\ 'ParseError: Cannot parse file.',
\ '',
\ 'index.py:11:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
\ 'index.py:16:81: E501 line too long (96 > 80 characters) [pycodestyle]',
\ ])
" Note: This is probably a bug, since all pylama plugins produce codes, but
" should be handled for compatibility.
" Note: The pylama isort plugin is distributed in the isort package.
Execute(The pylama handler should handle messages without codes with version older than 8.1.4):
AssertEqual
\ [
\ {
\ 'lnum': 0,
\ 'col': 0,
\ 'code': '',
\ 'type': 'W',
\ 'sub_type': '',
\ 'text': 'Incorrectly sorted imports. [isort]'
\ },
\ ],
\ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
\ 'index.py:0:0: Incorrectly sorted imports. [isort]',
\ ])
" Note: This is a pylama bug, but should be handled for compatibility.
" See https://github.com/klen/pylama/pull/146
Execute(The pylama handler should handle message codes followed by a colon with version older than 8.1.4):
AssertEqual
\ [
\ {
\ 'lnum': 31,
\ 'col': 1,
\ 'code': 'E800',
\ 'type': 'E',
\ 'sub_type': '',
\ 'text': 'Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
\ },
\ ],
\ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
\ 'index.py:31:1: E800: Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
\ ])
|