diff --git a/returns/maybe.py b/returns/maybe.py index 07dbe7ecd..c0d591baa 100644 --- a/returns/maybe.py +++ b/returns/maybe.py @@ -402,7 +402,7 @@ def __init__(self, inner_value: _ValueType) -> None: """Some constructor.""" super().__init__(inner_value) - if not TYPE_CHECKING: # noqa: WPS604 # pragma: no branch + if not TYPE_CHECKING: # noqa: WPS604,C901 # pragma: no branch def bind(self, function): """Binds current container to a function that returns container.""" return function(self._inner_value) @@ -415,6 +415,12 @@ def unwrap(self): """Returns inner value for successful container.""" return self._inner_value + def filter(self, function): + """Filters internal value.""" + if function(self._inner_value): + return self + return _Nothing() + def map(self, function): """Composes current container with a pure function.""" return Some(function(self._inner_value)) @@ -441,12 +447,6 @@ def failure(self): """Raises exception for successful container.""" raise UnwrapFailedError(self) - def filter(self, function): - """Filters internal value.""" - if function(self._inner_value): - return self - return _Nothing() - Maybe.success_type = Some Maybe.failure_type = _Nothing