Something went wrong while setting issue due date.
flake8 legacy api init_report does not return the instantiated Formatter
Again trying to fix https://github.com/asottile/cheetah_lint/issues/14
Related to #200 (closed)
Here's my current diff:
diff --git a/cheetah_lint/flake.py b/cheetah_lint/flake.py
index 6e204d8..5803530 100644
--- a/cheetah_lint/flake.py
+++ b/cheetah_lint/flake.py
@@ -8,10 +8,10 @@ import re
import sys
import tokenize
-import pycodestyle
from Cheetah.compile import compile_source
from Cheetah.legacy_compiler import LegacyCompiler
-from flake8.engine import get_style_guide
+from flake8.api.legacy import get_style_guide
+from flake8.api.legacy import formatter
from cheetah_lint import five
from cheetah_lint.util import read_file
@@ -83,13 +83,13 @@ def to_py(src):
)
-class DataCollectingReporter(pycodestyle.BaseReport):
- """A Reporter for pycodestyle/flake8 which simply collects data instead of
- spewing to stdout.
+class DataCollectingFormatter(formatter.BaseFormatter):
+ """A formatter for flake8 which simply collects data instead of spewing to
+ stdout.
"""
def __init__(self, *args, **kwargs):
- super(DataCollectingReporter, self).__init__(*args, **kwargs)
+ super(DataCollectingFormatter, self).__init__(*args, **kwargs)
self.data = []
def error(self, line_number, offset, text, check):
@@ -264,10 +264,10 @@ def normalize_line_numbers(data, py_lines, cheetah_lines):
def check_flake8(py_lines):
# Apologies, flake8 doesn't quite make this elegant / easy
checker = get_style_guide(select=SELECTED_ERRORS)
- reporter = checker.init_report(DataCollectingReporter)
+ checker.init_report(DataCollectingFormatter)
checker.input_file('<compiled cheetah>', py_lines)
return filter_known_unused_assignments(filter_known_unused_imports(
- reporter.data,
+ checker._application.formatter.data,
))
The last bit is pretty non-ideal (checker._application.formatter
)