diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-02 09:11:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-12-02 09:11:15 +0000 |
commit | 50dfafe3a01b634bfa80101fc199d3d451ff7d0f (patch) | |
tree | 944855d93ab99895019c54e66eba596c4a9e33ad /ptpython/validator.py | |
parent | Adding upstream version 3.0.20. (diff) | |
download | ptpython-86ba449b976b4833db71806f6f33f49a12a20bfe.tar.xz ptpython-86ba449b976b4833db71806f6f33f49a12a20bfe.zip |
Adding upstream version 3.0.21.upstream/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: |