##// END OF EJS Templates
Convert syntax warnings to errors when checking code completeness
Thomas Kluyver -
Show More
@@ -11,6 +11,7 b' from codeop import compile_command'
11 import re
11 import re
12 import tokenize
12 import tokenize
13 from typing import List, Tuple
13 from typing import List, Tuple
14 import warnings
14
15
15 _indent_re = re.compile(r'^[ \t]+')
16 _indent_re = re.compile(r'^[ \t]+')
16
17
@@ -536,7 +537,9 b' class TransformerManager:'
536 # We'll use codeop.compile_command to check this with the real parser.
537 # We'll use codeop.compile_command to check this with the real parser.
537
538
538 try:
539 try:
539 res = compile_command(''.join(lines), symbol='exec')
540 with warnings.catch_warnings():
541 warnings.simplefilter('error', SyntaxWarning)
542 res = compile_command(''.join(lines), symbol='exec')
540 except (SyntaxError, OverflowError, ValueError, TypeError,
543 except (SyntaxError, OverflowError, ValueError, TypeError,
541 MemoryError, SyntaxWarning):
544 MemoryError, SyntaxWarning):
542 return 'invalid', None
545 return 'invalid', None
General Comments 0
You need to be logged in to leave comments. Login now