Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,12 @@ def lint_and_format(code, enable_flake8, enable_pylint, enable_isort, enable_bla
|
|
28 |
app = flake8.main.application.Application()
|
29 |
app.initialize(['--format=default', temp_file_path])
|
30 |
app.run_checks()
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Pylint
|
35 |
if enable_pylint:
|
@@ -52,9 +56,8 @@ def lint_and_format(code, enable_flake8, enable_pylint, enable_isort, enable_bla
|
|
52 |
)
|
53 |
with open(temp_file_path, "r") as f:
|
54 |
formatted_code = f.read()
|
55 |
-
|
56 |
except black.NothingChanged:
|
57 |
-
pass
|
58 |
|
59 |
# AutoPEP8 (if Black is not enabled)
|
60 |
if not enable_black:
|
@@ -81,7 +84,6 @@ def main():
|
|
81 |
gr.Checkbox(label="Enable Pylint", value=False),
|
82 |
gr.Checkbox(label="Enable isort", value=True),
|
83 |
gr.Checkbox(label="Enable Black", value=True),
|
84 |
-
|
85 |
],
|
86 |
outputs=[
|
87 |
gr.Textbox(label="Flake8 Output"),
|
|
|
28 |
app = flake8.main.application.Application()
|
29 |
app.initialize(['--format=default', temp_file_path])
|
30 |
app.run_checks()
|
31 |
+
# Corrected Flake8 output retrieval
|
32 |
+
flake8_output_stream = io.StringIO()
|
33 |
+
app.report_formatter.output_file = flake8_output_stream
|
34 |
+
app.report_formatter.start()
|
35 |
+
app.report_formatter.stop()
|
36 |
+
flake8_output = flake8_output_stream.getvalue().strip()
|
37 |
|
38 |
# Pylint
|
39 |
if enable_pylint:
|
|
|
56 |
)
|
57 |
with open(temp_file_path, "r") as f:
|
58 |
formatted_code = f.read()
|
|
|
59 |
except black.NothingChanged:
|
60 |
+
pass
|
61 |
|
62 |
# AutoPEP8 (if Black is not enabled)
|
63 |
if not enable_black:
|
|
|
84 |
gr.Checkbox(label="Enable Pylint", value=False),
|
85 |
gr.Checkbox(label="Enable isort", value=True),
|
86 |
gr.Checkbox(label="Enable Black", value=True),
|
|
|
87 |
],
|
88 |
outputs=[
|
89 |
gr.Textbox(label="Flake8 Output"),
|