summaryrefslogtreecommitdiffstats
path: root/src/prompt_toolkit/filters/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/prompt_toolkit/filters/base.py')
-rw-r--r--src/prompt_toolkit/filters/base.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/prompt_toolkit/filters/base.py b/src/prompt_toolkit/filters/base.py
index afce6dc..410749d 100644
--- a/src/prompt_toolkit/filters/base.py
+++ b/src/prompt_toolkit/filters/base.py
@@ -30,7 +30,7 @@ class Filter(metaclass=ABCMeta):
"""
Chaining of filters using the & operator.
"""
- assert isinstance(other, Filter), "Expecting filter, got %r" % other
+ assert isinstance(other, Filter), f"Expecting filter, got {other!r}"
if isinstance(other, Always):
return self
@@ -48,7 +48,7 @@ class Filter(metaclass=ABCMeta):
"""
Chaining of filters using the | operator.
"""
- assert isinstance(other, Filter), "Expecting filter, got %r" % other
+ assert isinstance(other, Filter), f"Expecting filter, got {other!r}"
if isinstance(other, Always):
return other
@@ -193,7 +193,7 @@ class _Invert(Filter):
return not self.filter()
def __repr__(self) -> str:
- return "~%r" % self.filter
+ return f"~{self.filter!r}"
class Always(Filter):
@@ -207,6 +207,9 @@ class Always(Filter):
def __or__(self, other: Filter) -> Filter:
return self
+ def __and__(self, other: Filter) -> Filter:
+ return other
+
def __invert__(self) -> Never:
return Never()
@@ -222,6 +225,9 @@ class Never(Filter):
def __and__(self, other: Filter) -> Filter:
return self
+ def __or__(self, other: Filter) -> Filter:
+ return other
+
def __invert__(self) -> Always:
return Always()
@@ -248,7 +254,7 @@ class Condition(Filter):
return self.func()
def __repr__(self) -> str:
- return "Condition(%r)" % self.func
+ return f"Condition({self.func!r})"
# Often used as type annotation.