Better SyntaxError listings

This commit is contained in:
Dave Halter
2020-03-14 17:30:33 +01:00
parent 3cef022a15
commit 20fad922bc
3 changed files with 11 additions and 1 deletions

View File

@@ -8,3 +8,7 @@ API Return Classes
.. automodule:: jedi.api.classes .. automodule:: jedi.api.classes
:members: :members:
:undoc-members: :undoc-members:
.. autoclass:: jedi.api.errors.SyntaxError
:members:
:undoc-members:

View File

@@ -581,7 +581,9 @@ class Script(object):
def get_syntax_errors(self): def get_syntax_errors(self):
""" """
XXX Lists all syntax errors in the current file.
:rtype: list of :class:`.SyntaxError`
""" """
return parso_to_jedi_errors(self._inference_state.grammar, self._module_node) return parso_to_jedi_errors(self._inference_state.grammar, self._module_node)

View File

@@ -14,18 +14,22 @@ class SyntaxError(object):
@property @property
def line(self): def line(self):
"""The line where the error starts (starting with 1)."""
return self._parso_error.start_pos[0] return self._parso_error.start_pos[0]
@property @property
def column(self): def column(self):
"""The column where the error starts (starting with 0)."""
return self._parso_error.start_pos[1] return self._parso_error.start_pos[1]
@property @property
def until_line(self): def until_line(self):
"""The line where the error ends (starting with 1)."""
return self._parso_error.end_pos[0] return self._parso_error.end_pos[0]
@property @property
def until_column(self): def until_column(self):
"""The column where the error ends (starting with 0)."""
return self._parso_error.end_pos[1] return self._parso_error.end_pos[1]
def __repr__(self): def __repr__(self):