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

pyta-uoft / pyta / 15303879041

28 May 2025 03:13PM UTC coverage: 92.94% (-0.5%) from 93.487%
15303879041

Pull #1177

github

web-flow
Merge 4afd30083 into fc1c64f4d
Pull Request #1177: Refactor reporter loading and imports

28 of 49 new or added lines in 14 files covered. (57.14%)

3436 of 3697 relevant lines covered (92.94%)

17.6 hits per line

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

90.91
/python_ta/checkers/pycodestyle_checker.py
1
"""Checker for the style of the file"""
2

3
from __future__ import annotations
20✔
4

5
from typing import TYPE_CHECKING
20✔
6

7
import pycodestyle
20✔
8
from pylint.checkers import BaseRawFileChecker
20✔
9

10
if TYPE_CHECKING:
20✔
NEW
11
    from astroid import nodes
×
NEW
12
    from pylint.lint import PyLinter
×
13

14

15
class PycodestyleChecker(BaseRawFileChecker):
20✔
16
    """A checker class to report PEP8 style errors in the file.
17

18
    Use options to specify the list of PEP8 errors to ignore"""
19

20
    name = "pep8_errors"
20✔
21
    msgs = {"E9989": ("Found pycodestyle (PEP8) style error %s at %s", "pep8-errors", "")}
20✔
22

23
    options = (
20✔
24
        (
25
            "pycodestyle-ignore",
26
            {
27
                "default": (),
28
                "type": "csv",
29
                "metavar": "<pycodestyle-ignore>",
30
                "help": "List of Pycodestyle errors to ignore",
31
            },
32
        ),
33
    )
34

35
    def process_module(self, node: nodes.Module) -> None:
20✔
36
        style_guide = pycodestyle.StyleGuide(
20✔
37
            paths=[node.file],
38
            reporter=JSONReport,
39
            ignore=self.linter.config.pycodestyle_ignore,
40
        )
41
        report = style_guide.check_files()
20✔
42

43
        for line_num, msg, code in report.get_file_results():
20✔
44
            self.add_message("pep8-errors", line=line_num, args=(code, msg))
20✔
45

46

47
class JSONReport(pycodestyle.StandardReport):
20✔
48
    def get_file_results(self) -> list[tuple]:
20✔
49
        self._deferred_print.sort()
20✔
50
        return [
20✔
51
            (line_number, f"line {line_number}, column {offset}: {text}", code)
52
            for line_number, offset, code, text, _ in self._deferred_print
53
        ]
54

55

56
def register(linter: PyLinter) -> None:
20✔
57
    """Required method to auto-register this checker to the linter"""
58
    linter.register_checker(PycodestyleChecker(linter))
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