1 """ 2 This file is about errors in Python files and not about exception handling in 3 Jedi. 4 """ 5 6 7 def parso_to_jedi_errors(grammar, module_node): 8 return [SyntaxError(e) for e in grammar.iter_errors(module_node)] 9 10 11 class SyntaxError: 12 """ 13 Syntax errors are generated by :meth:`.Script.get_syntax_errors`. 14 """ 15 def __init__(self, parso_error): 16 self._parso_error = parso_error 17 18 @property 19 def line(self): 20 """The line where the error starts (starting with 1).""" 21 return self._parso_error.start_pos[0] 22 23 @property 24 def column(self): 25 """The column where the error starts (starting with 0).""" 26 return self._parso_error.start_pos[1] 27 28 @property 29 def until_line(self): 30 """The line where the error ends (starting with 1).""" 31 return self._parso_error.end_pos[0] 32 33 @property 34 def until_column(self): 35 """The column where the error ends (starting with 0).""" 36 return self._parso_error.end_pos[1] 37 38 def get_message(self): 39 return self._parso_error.message 40 41 def __repr__(self): 42 return '<%s from=%s to=%s>' % ( 43 self.__class__.__name__, 44 self._parso_error.start_pos, 45 self._parso_error.end_pos, 46 ) 47