devendergarg14 commited on
Commit
7de6028
·
verified ·
1 Parent(s): 4b9f75c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -34,24 +34,35 @@ class ErrorReporter(Reporter):
34
  def check_code_with_pyflakes(code_str: str) -> str:
35
  """
36
  Analyzes a string of Python code using pyflakes and returns a formatted error report.
37
- Returns an empty string if no errors are found.
 
38
  """
39
  reporter = ErrorReporter()
40
  check(code_str, "scene.py", reporter=reporter)
41
 
42
- if not reporter.errors:
 
 
 
 
 
 
 
 
 
43
  return "" # No errors found
44
 
45
- # Format the error list into a user-friendly string
46
  error_report = "Static analysis found potential errors:\n"
47
- for err in reporter.errors:
48
- # Example raw error: 'scene.py:5:21: undefined name 'Cirle''
49
  match = re.search(r'scene\.py:(\d+):.*(undefined name.*)', str(err))
50
  if match:
51
  line_num = match.group(1)
52
  error_msg = match.group(2)
53
  error_report += f"- Line {line_num}: {error_msg}\n"
54
  else:
 
55
  error_report += f"- {err}\n"
56
 
57
  return error_report
 
34
  def check_code_with_pyflakes(code_str: str) -> str:
35
  """
36
  Analyzes a string of Python code using pyflakes and returns a formatted error report.
37
+ Crucially, it filters out warnings related to star imports (`from manim import *`).
38
+ Returns an empty string if no definite errors are found.
39
  """
40
  reporter = ErrorReporter()
41
  check(code_str, "scene.py", reporter=reporter)
42
 
43
+ # --- START: New Filtering Logic ---
44
+ filtered_errors = []
45
+ for err in reporter.errors:
46
+ err_str = str(err)
47
+ # This is the key: we ignore the specific warnings about star imports.
48
+ if "may be undefined, or defined from star imports" not in err_str:
49
+ filtered_errors.append(err_str)
50
+ # --- END: New Filtering Logic ---
51
+
52
+ if not filtered_errors:
53
  return "" # No errors found
54
 
55
+ # Format the filtered error list into a user-friendly string
56
  error_report = "Static analysis found potential errors:\n"
57
+ for err in filtered_errors:
58
+ # We now process the filtered list, not the original one.
59
  match = re.search(r'scene\.py:(\d+):.*(undefined name.*)', str(err))
60
  if match:
61
  line_num = match.group(1)
62
  error_msg = match.group(2)
63
  error_report += f"- Line {line_num}: {error_msg}\n"
64
  else:
65
+ # Add a catch-all for other potential errors like syntax errors
66
  error_report += f"- {err}\n"
67
 
68
  return error_report