Skip to content

Commit

Permalink
Hide SyntaxWarnings from problematic history entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Oct 19, 2023
1 parent b2f099c commit 280ed10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ipython_autoimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import token
from types import ModuleType
import warnings

import IPython.core
from IPython.core import magic
Expand Down Expand Up @@ -70,7 +71,9 @@ def visit_ImportFrom(self, node):
pass
else:
try:
parsed = ast.parse(entry)
with warnings.catch_warnings():
warnings.simplefilter("ignore", SyntaxWarning)
parsed = ast.parse(entry)
except SyntaxError:
continue
Visitor().visit(parsed)
Expand Down

0 comments on commit 280ed10

Please sign in to comment.