From e5f7a41d988de298069eda636e823f374b973bd4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 18:33:15 +0200 Subject: Adding upstream version 3.0.26. Signed-off-by: Daniel Baumann --- ptpython/filters.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 ptpython/filters.py (limited to 'ptpython/filters.py') diff --git a/ptpython/filters.py b/ptpython/filters.py new file mode 100644 index 0000000..a2079fd --- /dev/null +++ b/ptpython/filters.py @@ -0,0 +1,39 @@ +from __future__ import annotations + +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: + super().__init__() + 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 -- cgit v1.2.3