@@ -141,23 +141,29 @@ def bind_optional(
141141
142142 """
143143
144- def filter (self ,
145- function : Callable [[_ValueType ], bool ],
146- ) -> 'Maybe[_ValueType]' :
144+ def filter (
145+ self ,
146+ function : Callable [[_ValueType ], bool ],
147+ ) -> 'Maybe[_ValueType]' :
147148 """
148- Apply a predicate over the value. If the predicate returns true it returns the original value wrapped with Some.
149+ Apply a predicate over the value.
150+
151+ If the predicate returns true,
152+ it returns the original value wrapped with Some.
149153 If the predicate returns false, Nothing is returned
150154
151155 .. code:: python
152156
153- >>> from returns.maybe import Maybe, Some, Nothing
157+ >>> from returns.maybe import Some, Nothing
154158 >>> def predicate(value):
155159 ... return value % 2 == 0
156160
157161 >>> assert Some(5).filter(predicate) == Nothing
158162 >>> assert Some(6).filter(predicate) == Some(6)
159163 >>> assert Nothing.filter(predicate) == Nothing
164+
160165 """
166+
161167 def lash (
162168 self ,
163169 function : Callable [[Any ], Kind1 ['Maybe' , _ValueType ]],
@@ -356,7 +362,7 @@ def bind_optional(self, function):
356362 return self
357363
358364 def filter (self , function ):
359- """Does nothing for ``Nothing`` """
365+ """Does nothing. """
360366 return self
361367
362368 def lash (self , function ):
@@ -436,10 +442,10 @@ def failure(self):
436442 raise UnwrapFailedError (self )
437443
438444 def filter (self , function ):
445+ """Filters internal value."""
439446 if function (self ._inner_value ):
440447 return self
441- else :
442- return _Nothing ()
448+ return _Nothing ()
443449
444450
445451Maybe .success_type = Some
@@ -475,7 +481,9 @@ def maybe(
475481 Requires our :ref:`mypy plugin <mypy-plugins>`.
476482
477483 """
484+
478485 @wraps (function )
479486 def decorator (* args , ** kwargs ):
480487 return Maybe .from_optional (function (* args , ** kwargs ))
488+
481489 return decorator
0 commit comments