diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-02 09:11:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-02 09:11:43 +0000 |
commit | 5c1d7c2dcc939f95e0dd53831a76341bbab89894 (patch) | |
tree | 77b46b51ed832aaa31c9745eea7baaf5c8bb48e4 /ptpython/validator.py | |
parent | Releasing debian version 3.0.20-2. (diff) | |
download | ptpython-5c1d7c2dcc939f95e0dd53831a76341bbab89894.tar.xz ptpython-5c1d7c2dcc939f95e0dd53831a76341bbab89894.zip |
Merging upstream version 3.0.21.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ptpython/validator.py')
-rw-r--r-- | ptpython/validator.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ptpython/validator.py b/ptpython/validator.py index 0f6a4ea..ffac583 100644 --- a/ptpython/validator.py +++ b/ptpython/validator.py @@ -1,3 +1,6 @@ +from typing import Callable, Optional + +from prompt_toolkit.document import Document from prompt_toolkit.validation import ValidationError, Validator from .utils import unindent_code @@ -13,10 +16,10 @@ class PythonValidator(Validator): active compiler flags. """ - def __init__(self, get_compiler_flags=None): + def __init__(self, get_compiler_flags: Optional[Callable[[], int]] = None) -> None: self.get_compiler_flags = get_compiler_flags - def validate(self, document): + def validate(self, document: Document) -> None: """ Check input for Python syntax errors. """ @@ -45,7 +48,7 @@ class PythonValidator(Validator): # fixed in Python 3.) # TODO: This is not correct if indentation was removed. index = document.translate_row_col_to_index( - e.lineno - 1, (e.offset or 1) - 1 + (e.lineno or 1) - 1, (e.offset or 1) - 1 ) raise ValidationError(index, f"Syntax Error: {e}") except TypeError as e: |