diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-26 04:10:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-26 04:10:02 +0000 |
commit | 227038a454943a075c51b60988c53f77a605fa10 (patch) | |
tree | 15d438e5519a2ba9ee7ba8c6f864bbc597ea33b5 /ptpython/filters.py | |
parent | Initial commit. (diff) | |
download | ptpython-227038a454943a075c51b60988c53f77a605fa10.tar.xz ptpython-227038a454943a075c51b60988c53f77a605fa10.zip |
Adding upstream version 3.0.16.upstream/3.0.16
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ptpython/filters.py')
-rw-r--r-- | ptpython/filters.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ptpython/filters.py b/ptpython/filters.py new file mode 100644 index 0000000..1adac13 --- /dev/null +++ b/ptpython/filters.py @@ -0,0 +1,36 @@ +from typing import TYPE_CHECKING + +from prompt_toolkit.filters import Filter + +if TYPE_CHECKING: + from .python_input import PythonInput + +__all__ = ["HasSignature", "ShowSidebar", "ShowSignature", "ShowDocstring"] + + +class PythonInputFilter(Filter): + def __init__(self, python_input: "PythonInput") -> None: + self.python_input = python_input + + def __call__(self) -> bool: + raise NotImplementedError + + +class HasSignature(PythonInputFilter): + def __call__(self) -> bool: + return bool(self.python_input.signatures) + + +class ShowSidebar(PythonInputFilter): + def __call__(self) -> bool: + return self.python_input.show_sidebar + + +class ShowSignature(PythonInputFilter): + def __call__(self) -> bool: + return self.python_input.show_signature + + +class ShowDocstring(PythonInputFilter): + def __call__(self) -> bool: + return self.python_input.show_docstring |