Skip to content

Commit

Permalink
[#34] Added basic generic support to string filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
todofixthis committed Oct 6, 2023
1 parent dee1b43 commit 0655557
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 57 deletions.
18 changes: 9 additions & 9 deletions filters/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def _apply(self, value):
return filtered if self._has_errors else filtered.date()


class Empty(BaseFilter):
class Empty(BaseFilter[T]):
"""
Expects the value to be empty.
Expand All @@ -405,7 +405,7 @@ def _apply(self, value):
)


class Item(BaseFilter):
class Item(BaseFilter[T]):
"""
Returns a single item from an incoming mapping or sequence.
"""
Expand Down Expand Up @@ -474,7 +474,7 @@ def _apply_sequence(self, value: typing.Sequence) -> typing.Any:
)


class Length(BaseFilter):
class Length(BaseFilter[T]):
"""
Ensures incoming values have exactly the right length.
"""
Expand Down Expand Up @@ -527,7 +527,7 @@ def _apply(self, value):
return value


class MaxLength(BaseFilter):
class MaxLength(BaseFilter[T]):
"""
Enforces a maximum length on the value.
"""
Expand Down Expand Up @@ -574,7 +574,7 @@ def _apply(self, value):
return value


class MinLength(BaseFilter):
class MinLength(BaseFilter[T]):
"""
Enforces a minimum length on the value.
"""
Expand Down Expand Up @@ -617,7 +617,7 @@ def _apply(self, value):
return value


class NoOp(BaseFilter):
class NoOp(BaseFilter[T]):
"""
Filter that does nothing, used when you need a placeholder Filter in a
FilterChain.
Expand All @@ -627,7 +627,7 @@ def _apply(self, value):
return value


class NotEmpty(BaseFilter):
class NotEmpty(BaseFilter[T]):
"""
Expects the value not to be empty.
Expand Down Expand Up @@ -675,7 +675,7 @@ def _apply_none(self):
return None


class Omit(BaseFilter):
class Omit(BaseFilter[T]):
"""
Returns a copy of an incoming mapping or sequence, with the specified keys
omitted. Any other items will be passed through.
Expand Down Expand Up @@ -815,7 +815,7 @@ def _get_default(self):
)


class Pick(BaseFilter):
class Pick(BaseFilter[T]):
"""
Returns a copy of an incoming mapping or sequence, with only the specified
keys included.
Expand Down
Loading

0 comments on commit 0655557

Please sign in to comment.