Spaces:
Runtime error
Runtime error
Commit ·
e4db90e
1
Parent(s): a198565
Update app.py
Browse files
app.py
CHANGED
|
@@ -123,13 +123,12 @@ class CodeGenerator:
|
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
-
|
| 127 |
import autopep8
|
| 128 |
import black
|
| 129 |
import isort
|
| 130 |
import pylint.lint
|
| 131 |
import autoimport
|
| 132 |
-
|
| 133 |
|
| 134 |
class PythonCodeFormatter:
|
| 135 |
def __init__(self, code):
|
|
@@ -154,6 +153,9 @@ class PythonCodeFormatter:
|
|
| 154 |
|
| 155 |
# Use autopep8 to fix any remaining issues
|
| 156 |
formatted_code = autopep8.fix_code(formatted_code)
|
|
|
|
|
|
|
|
|
|
| 157 |
return formatted_code
|
| 158 |
|
| 159 |
except RuntimeError as error:
|
|
|
|
| 123 |
|
| 124 |
|
| 125 |
|
|
|
|
| 126 |
import autopep8
|
| 127 |
import black
|
| 128 |
import isort
|
| 129 |
import pylint.lint
|
| 130 |
import autoimport
|
| 131 |
+
from yapf.yapflib.yapf_api import FormatCode # reformat a string of code
|
| 132 |
|
| 133 |
class PythonCodeFormatter:
|
| 134 |
def __init__(self, code):
|
|
|
|
| 153 |
|
| 154 |
# Use autopep8 to fix any remaining issues
|
| 155 |
formatted_code = autopep8.fix_code(formatted_code)
|
| 156 |
+
|
| 157 |
+
formatted_code, changed = FormatCode(formatted_code)
|
| 158 |
+
|
| 159 |
return formatted_code
|
| 160 |
|
| 161 |
except RuntimeError as error:
|