@@ -139,23 +139,29 @@ def bind_optional(
139139
140140 """
141141
142- def filter (self ,
143- function : Callable [[_ValueType ], bool ],
144- ) -> 'Maybe[_ValueType]' :
142+ def filter (
143+ self ,
144+ function : Callable [[_ValueType ], bool ],
145+ ) -> 'Maybe[_ValueType]' :
145146 """
146- Apply a predicate over the value. If the predicate returns true it returns the original value wrapped with Some.
147+ Apply a predicate over the value.
148+
149+ If the predicate returns true,
150+ it returns the original value wrapped with Some.
147151 If the predicate returns false, Nothing is returned
148152
149153 .. code:: python
150154
151- >>> from returns.maybe import Maybe, Some, Nothing
155+ >>> from returns.maybe import Some, Nothing
152156 >>> def predicate(value):
153157 ... return value % 2 == 0
154158
155159 >>> assert Some(5).filter(predicate) == Nothing
156160 >>> assert Some(6).filter(predicate) == Some(6)
157161 >>> assert Nothing.filter(predicate) == Nothing
162+
158163 """
164+
159165 def lash (
160166 self ,
161167 function : Callable [[Any ], Kind1 ['Maybe' , _ValueType ]],
@@ -352,7 +358,7 @@ def bind_optional(self, function):
352358 return self
353359
354360 def filter (self , function ):
355- """Does nothing for ``Nothing`` """
361+ """Does nothing. """
356362 return self
357363
358364 def lash (self , function ):
@@ -430,10 +436,10 @@ def failure(self):
430436 raise UnwrapFailedError (self )
431437
432438 def filter (self , function ):
439+ """Filters internal value."""
433440 if function (self ._inner_value ):
434441 return self
435- else :
436- return _Nothing ()
442+ return _Nothing ()
437443
438444
439445Maybe .success_type = Some
@@ -469,7 +475,9 @@ def maybe(
469475 Requires our :ref:`mypy plugin <mypy-plugins>`.
470476
471477 """
478+
472479 @wraps (function )
473480 def decorator (* args , ** kwargs ):
474481 return Maybe .from_optional (function (* args , ** kwargs ))
482+
475483 return decorator
0 commit comments