• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pyta-uoft / pyta / 18013112007

25 Sep 2025 03:15PM UTC coverage: 94.757% (-0.2%) from 94.944%
18013112007

Pull #1237

github

web-flow
Merge e530258ae into e586102d0
Pull Request #1237: refactoring node_printers.py

44 of 44 new or added lines in 1 file covered. (100.0%)

14 existing lines in 2 files now uncovered.

3524 of 3719 relevant lines covered (94.76%)

17.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.11
/python_ta/reporters/node_printers.py
1
"""Specify how errors should be rendered."""
2

3
import re
20✔
4
from enum import Enum
20✔
5

6
from astroid import nodes
20✔
7

8
NEW_BLANK_LINE_MESSAGE = "# INSERT NEW BLANK LINE HERE"
20✔
9

10

11
def render_message(msg, node, source_lines):
20✔
12
    """Render a message based on type."""
13
    renderer = CUSTOM_MESSAGES.get(msg.symbol, render_generic)
20✔
14
    yield from renderer(msg, node, source_lines)
20✔
15

16

17
def render_generic(msg, node=None, source_lines=None):
20✔
18
    """Default rendering for a message."""
19
    if node is not None:
20✔
20
        start_line, start_col = node.fromlineno, node.col_offset
20✔
21

22
        if isinstance(node, (nodes.FunctionDef, nodes.ClassDef)):
20✔
23
            end_line, end_col = start_line, None
20✔
24
        else:
25
            end_line, end_col = node.end_lineno, node.end_col_offset
20✔
26

27
        # Display up to 2 lines before node for context:
28
        yield from render_context(start_line - 2, start_line, source_lines)
20✔
29

30
        if start_line == end_line:
20✔
31
            yield (
20✔
32
                start_line,
33
                slice(start_col, end_col),
34
                LineType.ERROR,
35
                source_lines[start_line - 1],
36
            )
37
        else:
38
            yield (start_line, slice(start_col, None), LineType.ERROR, source_lines[start_line - 1])
20✔
39
            yield from (
20✔
40
                (line, slice(None, None), LineType.ERROR, source_lines[line - 1])
41
                for line in range(start_line + 1, end_line)
42
            )
43
            yield (end_line, slice(None, end_col), LineType.ERROR, source_lines[end_line - 1])
20✔
44

45
        # Display up to 2 lines after node for context:
46
        yield from render_context(end_line + 1, end_line + 3, source_lines)
20✔
47

48
    else:
49
        line = msg.line
20✔
50
        yield from render_context(line - 2, line, source_lines)
20✔
51
        yield (line, slice(None, None), LineType.ERROR, source_lines[line - 1])
20✔
52
        yield from render_context(line + 1, line + 3, source_lines)
20✔
53

54

55
def render_missing_docstring(_msg, node, source_lines=None):
20✔
56
    """Render a missing docstring message."""
57
    if isinstance(node, nodes.Module):
20✔
58
        yield (None, slice(None, None), LineType.DOCSTRING, '"""YOUR DOCSTRING HERE"""')
20✔
59
        yield from render_context(1, 3, source_lines)
20✔
60
    elif isinstance(node, nodes.ClassDef) or isinstance(node, nodes.FunctionDef):
20✔
61
        start = node.fromlineno
20✔
62
        end = node.body[0].fromlineno
20✔
63
        yield from render_context(start, end, source_lines)
20✔
64
        # Calculate indentation
65
        body = source_lines[end - 1]
20✔
66
        indentation = len(body) - len(body.lstrip())
20✔
67
        yield (
20✔
68
            None,
69
            slice(None, None),
70
            LineType.DOCSTRING,
71
            body[:indentation] + '"""YOUR DOCSTRING HERE"""',
72
        )
73
        yield from render_context(end, end + 2, source_lines)
20✔
74

75

76
def render_trailing_newlines(msg, _node, source_lines=None):
20✔
77
    """Render a trailing newlines message."""
78
    start_line = msg.line - 1
20✔
79
    yield from render_context(start_line - 2, start_line, source_lines)
20✔
80
    yield from (
20✔
81
        (line, slice(None, None), LineType.OTHER, source_lines[line - 1])
82
        for line in range(start_line, len(source_lines) + 1)
83
    )
84

85

86
def render_trailing_whitespace(msg, _node, source_lines=None):
20✔
87
    """Render a trailing whitespace message."""
88
    line = msg.line
20✔
89
    start_index, end_index = len(source_lines[line - 1].rstrip()), len(source_lines[line - 1])
20✔
90
    yield from render_context(line - 1, line, source_lines)
20✔
91
    yield (line, slice(start_index, end_index), LineType.ERROR, source_lines[line - 1])
20✔
92
    yield from render_context(line + 1, line + 2, source_lines)
20✔
93

94

95
def render_context(start, stop, source_lines):
20✔
96
    """Helper for rendering context lines."""
97
    start, stop = max(start, 1), min(stop, len(source_lines))
20✔
98
    yield from (
20✔
99
        (line, slice(None, None), LineType.CONTEXT, source_lines[line - 1])
100
        for line in range(start, stop)
101
    )
102

103

104
def render_missing_return_type(_msg, node, source_lines=None):
20✔
105
    """Render a type annotation return message."""
106
    start_line, start_col = node.fromlineno, node.parent.col_offset
20✔
107
    end_line, end_col = node.end_lineno, node.end_col_offset
20✔
108

109
    # Display up to 2 lines before node for context:
110
    yield from render_context(start_line - 2, start_line, source_lines)
20✔
111
    yield from (
20✔
112
        (line, slice(None, end_col + 1), LineType.ERROR, source_lines[line - 1])
113
        for line in range(start_line, end_line + 1)
114
    )
115
    # Display up to 2 lines after node for context:
116
    yield from render_context(end_line + 1, end_line + 3, source_lines)
20✔
117

118

119
def render_too_many_arguments(msg, node, source_lines=None):
20✔
120
    """Render a too many arguments message."""
121
    # node is a FunctionDef node so replace it with its Arguments child
122
    yield from render_generic(msg, node.args, source_lines)
20✔
123

124

125
def render_missing_space_in_doctest(msg, _node, source_lines=None):
20✔
126
    """Render a missing space in doctest message"""
127
    line = msg.line
20✔
128

129
    # Display 2 lines before and after the erroneous line
130
    yield from render_context(line - 2, line, source_lines)
20✔
131
    yield (line, slice(None, None), LineType.ERROR, source_lines[line - 1])
20✔
132
    yield from render_context(line + 1, line + 3, source_lines)
20✔
133

134

135
def get_col(msg):
20✔
136
    """Returns the column number of the character containing the error"""
137
    res = re.search(r"column (\d+)", msg.msg)
20✔
138
    col = int(res.group().split()[-1])
20✔
139
    return col
20✔
140

141

142
def render_pep8_errors(msg, _node, source_lines=None):
20✔
143
    """Render a PEP8 error message."""
144
    # Extract the raw error message
145
    raw_msg = getattr(msg, "msg", "")
20✔
146

147
    # Search for the first appearance of the error code in the extracted error text
148
    matched_error = re.search(r"(E\d{3})", raw_msg)
20✔
149
    if matched_error:
20✔
150
        error_code = matched_error.group(1)
20✔
151
        # Render the appropriate error through the RENDERERS dict
152
        if error_code in RENDERERS:
20✔
153
            line = msg.line
20✔
154
            col = get_col(msg)
20✔
155
            yield from render_context(line - 3, line, source_lines)
20✔
156
            yield from RENDERERS[error_code](msg, _node, line, col, source_lines[line - 1])
20✔
157
            yield from render_context(line + 1, line + 3, source_lines)
20✔
158
            return
20✔
159

160
    # If none of the error codes were present, render the error using the generic error renderer
161
    yield from render_generic(msg, _node, source_lines)
20✔
162

163

164
def render_blank_line(line):
20✔
165
    """Render a blank line for a PEP8 error message."""
166
    yield (line + 1, slice(None, None), LineType.ERROR, " " * 28)
20✔
167

168

169
def render_pep8_errors_e101_and_e123(msg, _node, line, col, source_line=None):
20✔
170
    """Render a PEP8 indentation contains mixed spaces and tabs message
171
    AND a PEP8 closing bracket does not match indentation of opening bracket's line message."""
172
    curr_idx = len(source_line) - len(source_line.lstrip())
20✔
173
    yield (line, slice(0, curr_idx), LineType.ERROR, source_line)
20✔
174

175

176
def render_pep8_errors_e115(msg, _node, line, col, source_line=None):
20✔
177
    """Render a PEP8 expected an indented block (comment) message."""
178
    yield (
20✔
179
        line,
180
        slice(0, len(source_line)),
181
        LineType.ERROR,
182
        source_line + "  # INDENT THIS LINE",
183
    )
184

185

186
def render_pep8_errors_e116(msg, _node, line, col, source_line=None):
20✔
187
    """Render a PEP8 unexpected indentation (comment) message"""
188
    curr_idx = len(source_line) - len(source_line.lstrip())
20✔
189
    yield (
20✔
190
        line,
191
        slice(0, curr_idx),
192
        LineType.ERROR,
193
        source_line,
194
    )
195

196

197
def render_pep8_errors_e122_and_e127_and_e131(msg, _node, line, col, source_line=None):
20✔
198
    """
199
    Render a PEP8 continuation line missing indentation or outdented message, a line over-indented for visual indent
200
    message, and a continuation line unaligned for hanging indent message.
201
    """
202

203
    curr_line_start_index = len(source_line) - len(source_line.lstrip())
20✔
204
    end_index = curr_line_start_index if curr_line_start_index > 0 else len(source_line)
20✔
205
    yield (
20✔
206
        line,
207
        slice(0, end_index),
208
        LineType.ERROR,
209
        source_line,
210
    )
211

212

213
def render_pep8_errors_e124(msg, _node, line, col, source_line=None):
20✔
214
    """Render a PEP8 closing bracket does not match visual indentation message."""
215

216
    yield (line, slice(col, col + 1), LineType.ERROR, source_line)
20✔
217

218

219
def render_pep8_errors_e125_and_e129(msg, _node, line, col, source_line=None):
20✔
220
    """Render a PEP8 continuation line with same indent as next logical line message
221
    AND a PEP8 visually indented line with same indent as next logical line messsage"""
222
    curr_idx = len(source_line) - len(source_line.lstrip())
20✔
223
    yield (
20✔
224
        line,
225
        slice(curr_idx, len(source_line)),
226
        LineType.ERROR,
227
        source_line + " " * 2 + "# INDENT THIS LINE",
228
    )
229

230

231
def render_pep8_errors_e128(msg, _node, line, col, source_line):
20✔
232
    """Render a PEP8 continuation line under-indented for visual indent message."""
233

234
    yield (line, slice(0, col if col != 0 else None), LineType.ERROR, source_line)
20✔
235

236

237
def render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272(
20✔
238
    msg, _node, line, col, source_line=None
239
):
240
    """Render a PEP8 whitespace after '(' message,
241
    a PEP8 whitespace before ')' message,
242
    a PEP8 whitespace before ‘,’, ‘;’, or ‘:’ message,
243
    a PEP8 whitespace before '(' message,
244
    a PEP8 multiple spaces before operator message,
245
    a PEP8 multiple spaces after keyword message,
246
    a PEP8 multiple spaces before keyword message
247
    and a PEP8 multiple spaces after operator message."""
248

249
    curr_idx = col + len(source_line[col:]) - len(source_line[col:].lstrip())
20✔
250

251
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
252

253

254
def render_pep8_errors_e204(msg, _node, line, col, source_line=None):
20✔
255
    """Render a PEP8 whitespace after decorator '@' message"""
256

257
    # calculates the length of the leading whitespaces by subtracting the length of everything after the first character after stripping all leading whitespaces from the total line length
258
    curr_idx = col + len(source_line[col:]) - len(source_line[col + 1 :].lstrip())
20✔
259

260
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
261

262

263
def render_pep8_errors_e223_and_e274(msg, _node, line, col, source_line=None):
20✔
264
    """Render a PEP8 tab before operator message and a PEP8 tab before keyword message."""
265

266
    curr_idx = col + len(source_line[col:]) - len(source_line[col:].lstrip("\t"))
20✔
267

268
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
269

270

271
def render_pep8_errors_e224_and_e273(msg, _node, line, col, source_line):
20✔
272
    """Render a PEP8 tab after operator message and a PEP8 tab after keyword message."""
273

274
    curr_idx = col + len(source_line[col:]) - len(source_line[col:].lstrip("\t"))
20✔
275

276
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
277

278

279
def render_pep8_errors_e225(msg, _node, line, col, source_line):
20✔
280
    """Render a PEP8 missing whitespace around operator message"""
281

282
    curr_idx = col + 1
20✔
283

284
    two_char_operators = {
20✔
285
        "==",
286
        ">=",
287
        "<=",
288
        "!=",
289
        ":=",
290
        "&=",
291
        "->",
292
        "%=",
293
        "/=",
294
        "+=",
295
        "-=",
296
        "*=",
297
        "|=",
298
        "^=",
299
        "@=",
300
    }
301
    three_char_operators = {"//=", ">>=", "<<=", "**="}
20✔
302
    # highlight multiple characters for operators that are longer than one character
303
    if source_line[col : col + 2] in two_char_operators:
20✔
304
        curr_idx += 1
20✔
305
    elif source_line[col : col + 3] in three_char_operators:
20✔
306
        curr_idx += 2
20✔
307

308
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
309

310

311
def render_pep8_errors_e226(msg, _node, line, col, source_line):
20✔
312
    """Render a PEP8 missing whitespace around arithmetic operator message"""
313

314
    end_idx = col + 1
20✔
315

316
    multi_char_operators = {"//"}
20✔
317
    # highlight multiple characters for arithmetic operators that are longer than one character
318
    if source_line[col : col + 2] in multi_char_operators:
20✔
319
        end_idx += 1
20✔
320

321
    yield (line, slice(col, end_idx), LineType.ERROR, source_line)
20✔
322

323

324
def render_pep8_errors_e227(msg, _node, line, col, source_line=None):
20✔
325
    """Render a PEP8 missing whitespace around bitwise or shift operator message."""
326

327
    # Check which operator to get the correct range of the line to highlight.
328
    # Default highlight is one character, but may be updated to two.
329
    # Note that only binary bitwise operators that are more than one character are included.
330
    operators = {">>", "<<"}
20✔
331
    end_idx = col + 1
20✔
332
    end_idx = end_idx + 1 if source_line[col : col + 2] in operators else end_idx
20✔
333

334
    yield (line, slice(col, end_idx), LineType.ERROR, source_line)
20✔
335

336

337
def render_pep8_errors_e228(msg, _node, line, col, source_line=None):
20✔
338
    """Render a PEP8 missing whitespace around modulo operator message."""
339

340
    yield (
20✔
341
        line,
342
        slice(col, col + 1),
343
        LineType.ERROR,
344
        source_line + "  # INSERT A SPACE BEFORE AND AFTER THE % OPERATOR",
345
    )
346

347

348
def render_pep8_errors_e231(msg, _node, line, col, source_line=None):
20✔
349

350
    curr_idx = col + 1
20✔
351

352
    yield (line, slice(col, curr_idx), LineType.ERROR, source_line)
20✔
353

354

355
def render_pep8_errors_e251(msg, _node, line, col, source_line=None):
20✔
356
    """Render a PEP8 unexpected spaces around keyword / parameter equals message."""
357

358
    equals_sign_idx = source_line[col:].find("=")
20✔
359
    code = source_line[col : col + equals_sign_idx if equals_sign_idx != -1 else None]
20✔
360
    end_idx = col + len(code) - len(code.lstrip())
20✔
361

362
    yield (line, slice(col, end_idx), LineType.ERROR, source_line)
20✔
363

364

365
def render_pep8_errors_e261(msg, _node, line, col, source_line=None):
20✔
366
    """Render a PEP8 at least two spaces before inline comment message."""
367

368
    yield (
20✔
369
        line,
370
        slice(col, len(source_line)),
371
        LineType.ERROR,
372
        source_line + "  # INSERT TWO SPACES BEFORE THE '#'",
373
    )
374

375

376
def render_pep8_errors_e262(msg, _node, line, col, source_line=None):
20✔
377
    """Render a PEP8 inline comment should start with '# ' message"""
378

379
    keyword_idx = len(source_line) - len(source_line[col:].lstrip("# \t"))
20✔
380

381
    yield (line, slice(col, keyword_idx), LineType.ERROR, source_line)
20✔
382

383

384
def render_pep8_errors_e265(msg, _node, line, col, source_line=None):
20✔
385
    """Render a PEP8 block comment should start with '# ' message."""
386

387
    yield (
20✔
388
        line,
389
        slice(0, len(source_line)),
390
        LineType.ERROR,
391
        source_line + "  # INSERT SPACE AFTER THE '#'",
392
    )
393

394

395
def render_pep8_errors_e266(msg, _node, line, col, source_line=None):
20✔
396
    """Render a PEP8 too many leading ‘#’ for block comment message."""
397

398
    curr_idx = col + len(source_line[col:]) - len(source_line[col:].lstrip("#"))
20✔
399

400
    yield (
20✔
401
        line,
402
        slice(col, curr_idx),
403
        LineType.ERROR,
404
        source_line + "  # THERE SHOULD ONLY BE ONE '#'",
405
    )
406

407

408
def render_pep8_errors_e275(msg, _node, line, col, source_line=None):
20✔
409
    """Render a PEP8 missing whitespace after keyword message."""
410

411
    # Get the range for highlighting the corresponding keyword.
412
    keyword = source_line[:col].split()[-1]
20✔
413
    keyword_idx = source_line.index(keyword)
20✔
414

415
    yield (
20✔
416
        line,
417
        slice(keyword_idx, col),
418
        LineType.ERROR,
419
        source_line + "  # INSERT SPACE AFTER KEYWORD",
420
    )
421

422

423
def render_pep8_errors_e301(msg, _node, line, col, source_line=None):
20✔
424
    """Render a PEP8 expected 1 blank line message."""
425
    line -= 1
20✔
426

427
    body = source_line[line]
20✔
428
    indentation = len(body) - len(body.lstrip())
20✔
429
    yield (
20✔
430
        None,
431
        slice(None, None),
432
        LineType.ERROR,
433
        body[:indentation] + NEW_BLANK_LINE_MESSAGE,
434
    )
435

436

437
def render_pep8_errors_e302(msg, _node, line, col, source_line=None):
20✔
438
    """Render a PEP8 expected 2 blank lines message."""
439
    line -= 1
20✔
440
    if "found 0" in msg.msg:
20✔
441
        yield from (
20✔
442
            (
443
                None,
444
                slice(None, None),
445
                LineType.ERROR,
446
                NEW_BLANK_LINE_MESSAGE,
447
            )
448
            for _ in range(0, 2)
449
        )
450
    else:
451
        line -= 1
20✔
452
        yield from render_blank_line(line)
20✔
453
        yield (None, slice(None, None), LineType.ERROR, NEW_BLANK_LINE_MESSAGE)
20✔
454

455

456
def render_pep8_errors_e303(msg, _node, line, col, source_line=None):
20✔
457
    """Render a PEP8 too many blank lines message."""
458
    line -= 1
20✔
459
    while source_line.strip() == "":
20✔
UNCOV
460
        line -= 1
×
461

462
    body = source_line[msg.line - 1]
20✔
463
    indentation = len(body) - len(body.lstrip())
20✔
464
    yield from (
20✔
465
        (curr_line, slice(None, None), LineType.ERROR, " " * (indentation + 28))
466
        for curr_line in range(line + 1, msg.line)
467
    )
468

469

470
def render_pep8_errors_e304(msg, _node, line, col, source_line=None):
20✔
471
    """Render a PEP8 blank lines found after function decorator message."""
472
    line -= 1
20✔
473
    while source_line.strip() == "":
20✔
UNCOV
474
        line -= 1
×
475

476
    yield from (
20✔
477
        (curr_line, slice(None, None), LineType.ERROR, " " * 28)
478
        for curr_line in range(line + 1, msg.line)
479
    )
480

481

482
def render_pep8_errors_e305(msg, _node, line, col, source_line=None):
20✔
483
    """Render a PEP8 expected 2 blank lines after class or function definition message."""
484
    line -= 1
20✔
485
    if "found 0" in msg.msg:
20✔
486
        yield from (
20✔
487
            (
488
                None,
489
                slice(None, None),
490
                LineType.ERROR,
491
                NEW_BLANK_LINE_MESSAGE,
492
            )
493
            for _ in range(0, 2)
494
        )
495
    else:
496
        line -= 1
20✔
497
        yield from render_blank_line(line)
20✔
498
        yield (None, slice(None, None), LineType.ERROR, NEW_BLANK_LINE_MESSAGE)
20✔
499

500

501
def render_pep8_errors_e306(msg, _node, line, col, source_line=None):
20✔
502
    """Render a PEP8 expected 1 blank line before a nested definition message."""
503
    line -= 1
20✔
504
    body = source_line[line]
20✔
505
    indentation = len(body) - len(body.lstrip())
20✔
506
    yield (
20✔
507
        None,
508
        slice(None, None),
509
        LineType.ERROR,
510
        body[:indentation] + NEW_BLANK_LINE_MESSAGE,
511
    )
512

513

514
def render_pep8_errors_e502(msg, _node, line, col, source_line=None):
20✔
515
    """Render a PEP8 the backslash is redundant between brackets."""
516
    yield (line, slice(col, col + 1), LineType.ERROR, source_line)
20✔
517

518

519
def render_missing_return_statement(msg, node, source_lines=None):
20✔
520
    """
521
    Render a missing return statements message
522
    """
523
    yield from render_context(msg.line, msg.end_line + 1, source_lines)
20✔
524

525
    # calculate indentation for the insertion point
526
    body = source_lines[msg.end_line - 1]
20✔
527
    indentation = len(source_lines[msg.line - 1]) - len(source_lines[msg.line - 1].lstrip())
20✔
528

529
    # determine whether reaching the end of function
530
    first_statement_line = node.end_lineno if len(node.body) == 0 else node.body[0].lineno
20✔
531
    function_indentation = len(source_lines[first_statement_line - 1]) - len(
20✔
532
        source_lines[first_statement_line - 1].lstrip()
533
    )
534

535
    if msg.end_line == node.end_lineno and indentation == function_indentation:
20✔
536
        insertion_text = body[:indentation] + "# INSERT RETURN STATEMENT HERE"
20✔
537
    else:
538
        insertion_text = body[:indentation] + "# INSERT RETURN STATEMENT HERE (OR BELOW)"
20✔
539

540
    # insert the message
541
    yield (
20✔
542
        None,
543
        slice(indentation, None),
544
        LineType.ERROR,
545
        insertion_text,
546
    )
547

548
    yield from render_context(msg.end_line + 1, msg.end_line + 3, source_lines)
20✔
549

550

551
def render_static_type_checker_errors(msg, _node=None, source_lines=None):
20✔
552
    """Render a message for incompatible argument types."""
553
    start_line = msg.line
20✔
554
    start_col = msg.column
20✔
555
    end_line = msg.end_line
20✔
556
    end_col = msg.end_column
20✔
557
    yield from render_context(start_line - 2, start_line, source_lines)
20✔
558

559
    if start_line == end_line:
20✔
560
        yield (
20✔
561
            start_line,
562
            slice(start_col - 1, end_col),
563
            LineType.ERROR,
564
            source_lines[start_line - 1],
565
        )
566
    else:
567
        yield (start_line, slice(start_col - 1, None), LineType.ERROR, source_lines[start_line - 1])
20✔
568
        yield from (
20✔
569
            (line, slice(None, None), LineType.ERROR, source_lines)
570
            for line in range(start_line + 1, end_line)
571
        )
572
        yield (end_line, slice(None, end_col), LineType.ERROR, source_lines[end_line - 1])
20✔
573
    yield from render_context(end_line + 1, end_line + 3, source_lines)
20✔
574

575

576
CUSTOM_MESSAGES = {
20✔
577
    "missing-module-docstring": render_missing_docstring,
578
    "missing-class-docstring": render_missing_docstring,
579
    "missing-function-docstring": render_missing_docstring,
580
    "trailing-newlines": render_trailing_newlines,
581
    "trailing-whitespace": render_trailing_whitespace,
582
    "missing-return-type": render_missing_return_type,
583
    "too-many-arguments": render_too_many_arguments,
584
    "missing-space-in-doctest": render_missing_space_in_doctest,
585
    "pep8-errors": render_pep8_errors,
586
    "missing-return-statement": render_missing_return_statement,
587
    "incompatible-argument-type": render_static_type_checker_errors,
588
    "incompatible-assignment": render_static_type_checker_errors,
589
    "list-item-type-mismatch": render_static_type_checker_errors,
590
    "unsupported-operand-types": render_static_type_checker_errors,
591
    "union-attr-error": render_static_type_checker_errors,
592
    "dict-item-type-mismatch": render_static_type_checker_errors,
593
}
594

595
RENDERERS = {
20✔
596
    "E101": render_pep8_errors_e101_and_e123,
597
    "E123": render_pep8_errors_e101_and_e123,
598
    "E115": render_pep8_errors_e115,
599
    "E116": render_pep8_errors_e116,
600
    "E122": render_pep8_errors_e122_and_e127_and_e131,
601
    "E127": render_pep8_errors_e122_and_e127_and_e131,
602
    "E131": render_pep8_errors_e122_and_e127_and_e131,
603
    "E124": render_pep8_errors_e124,
604
    "E125": render_pep8_errors_e125_and_e129,
605
    "E129": render_pep8_errors_e125_and_e129,
606
    "E128": render_pep8_errors_e128,
607
    "E201": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
608
    "E202": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
609
    "E203": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
610
    "E204": render_pep8_errors_e204,
611
    "E211": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
612
    "E221": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
613
    "E222": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
614
    "E223": render_pep8_errors_e223_and_e274,
615
    "E224": render_pep8_errors_e224_and_e273,
616
    "E225": render_pep8_errors_e225,
617
    "E231": render_pep8_errors_e231,
618
    "E273": render_pep8_errors_e224_and_e273,
619
    "E274": render_pep8_errors_e223_and_e274,
620
    "E226": render_pep8_errors_e226,
621
    "E227": render_pep8_errors_e227,
622
    "E228": render_pep8_errors_e228,
623
    "E251": render_pep8_errors_e251,
624
    "E261": render_pep8_errors_e261,
625
    "E262": render_pep8_errors_e262,
626
    "E265": render_pep8_errors_e265,
627
    "E266": render_pep8_errors_e266,
628
    "E271": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
629
    "E272": render_pep8_errors_e201_e202_e203_e211_e221_e222_e271_e272,
630
    "E275": render_pep8_errors_e275,
631
    "E301": render_pep8_errors_e301,
632
    "E302": render_pep8_errors_e302,
633
    "E303": render_pep8_errors_e303,
634
    "E304": render_pep8_errors_e304,
635
    "E305": render_pep8_errors_e305,
636
    "E306": render_pep8_errors_e306,
637
    "E502": render_pep8_errors_e502,
638
}
639

640

641
class LineType(Enum):
20✔
642
    """An enumeration for _add_line method line types."""
643

644
    ERROR = 1  # line with error
20✔
645
    CONTEXT = 2  # non-error/other line added for context
20✔
646
    OTHER = 3  # line included in source but not error
20✔
647
    ELLIPSIS = 5  # code replaced with ellipsis
20✔
648
    DOCSTRING = 6  # docstring needed warning
20✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc