summaryrefslogtreecommitdiffstats
path: root/ptpython/filters.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:33:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:33:15 +0000
commite5f7a41d988de298069eda636e823f374b973bd4 (patch)
treea6a97f4d2ed5e59ab11cbae6b403ddebc5effe00 /ptpython/filters.py
parentInitial commit. (diff)
downloadptpython-upstream.tar.xz
ptpython-upstream.zip
Adding upstream version 3.0.26.upstream/3.0.26upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ptpython/filters.py')
-rw-r--r--ptpython/filters.py39
1 files changed, 39 insertions, 0 deletions
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