Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active fail_on_warning RTD #614

Merged
merged 4 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

python:
version: 3.7
install:
- docs/requirements.txt

sphinx:
configuration: docs/conf.py
fail_on_warning: true

formats: all
2 changes: 2 additions & 0 deletions docs/pages/railway.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ inner state of containers into a regular types:
>>> assert Some(0).unwrap() == 0

.. code:: pycon
:force:

>>> Failure(1).unwrap()
Traceback (most recent call last):
Expand All @@ -160,6 +161,7 @@ use :func:`.failure <returns.interfaces.unwrappable.Unwrapable.failure>`
to unwrap the failed state:

.. code:: pycon
:force:

>>> assert Failure(1).failure() == 1
>>> Success(1).failure()
Expand Down
32 changes: 17 additions & 15 deletions returns/context/requires_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -87,7 +89,7 @@ class RequiresContext(
"""

#: This field has an extra 'RequiresContext' just because `mypy` needs it.
_inner_value: Callable[['RequiresContext', _EnvType], _ReturnType]
_inner_value: Callable[[RequiresContext, _EnvType], _ReturnType]

#: A convenient placeholder to call methods created by `.from_value()`:
empty: ClassVar[NoDeps] = object()
Expand Down Expand Up @@ -136,7 +138,7 @@ def __call__(self, deps: _EnvType) -> _ReturnType:

def map( # noqa: WPS125
self, function: Callable[[_ReturnType], _NewReturnType],
) -> 'RequiresContext[_NewReturnType, _EnvType]':
) -> RequiresContext[_NewReturnType, _EnvType]:
"""
Allows to compose functions inside the wrapped container.

Expand Down Expand Up @@ -164,7 +166,7 @@ def apply(
Callable[[_ReturnType], _NewReturnType],
_EnvType,
],
) -> 'RequiresContext[_NewReturnType, _EnvType]':
) -> RequiresContext[_NewReturnType, _EnvType]:
"""
Calls a wrapped function in a container on this container.

Expand All @@ -186,7 +188,7 @@ def bind(
[_ReturnType],
Kind2['RequiresContext', _NewReturnType, _EnvType],
],
) -> 'RequiresContext[_NewReturnType, _EnvType]':
) -> RequiresContext[_NewReturnType, _EnvType]:
"""
Composes a container with a function returning another container.

Expand Down Expand Up @@ -221,7 +223,7 @@ def bind(
def modify_env(
self,
function: Callable[[_NewEnvType], _EnvType],
) -> 'RequiresContext[_ReturnType, _NewEnvType]':
) -> RequiresContext[_ReturnType, _NewEnvType]:
"""
Allows to modify the environment type.

Expand All @@ -238,7 +240,7 @@ def modify_env(
return RequiresContext(lambda deps: self(function(deps)))

@classmethod
def ask(cls) -> 'RequiresContext[_EnvType, _EnvType]':
def ask(cls) -> RequiresContext[_EnvType, _EnvType]:
"""
Get current context to use the dependencies.

Expand Down Expand Up @@ -316,13 +318,13 @@ def ask(cls) -> 'RequiresContext[_EnvType, _EnvType]':
See also:
https://dev.to/gcanti/getting-started-with-fp-ts-reader-1ie5

"""
""" # noqa: F811
thepabloaguilar marked this conversation as resolved.
Show resolved Hide resolved
return RequiresContext(identity)

@classmethod
def from_value(
cls, inner_value: _FirstType,
) -> 'RequiresContext[_FirstType, NoDeps]':
) -> RequiresContext[_FirstType, NoDeps]:
"""
Used to return some specific value from the container.

Expand All @@ -343,8 +345,8 @@ def from_value(

@classmethod
def from_context(
cls, inner_value: 'RequiresContext[_NewReturnType, _NewEnvType]',
) -> 'RequiresContext[_NewReturnType, _NewEnvType]':
cls, inner_value: RequiresContext[_NewReturnType, _NewEnvType],
) -> RequiresContext[_NewReturnType, _NewEnvType]:
"""
Used to create new containers from existing ones.

Expand All @@ -363,10 +365,10 @@ def from_context(
def from_iterable(
cls,
inner_value: Iterable[
Kind2['RequiresContext', _NewReturnType, _NewEnvType],
Kind2[RequiresContext, _NewReturnType, _NewEnvType],
],
strategy: Type[BaseIterableStrategyN] = FailFast,
) -> 'RequiresContext[Sequence[_NewReturnType], _NewEnvType]':
) -> RequiresContext[Sequence[_NewReturnType], _NewEnvType]:
"""
Transforms an iterable of ``RequiresContext`` containers.

Expand All @@ -388,7 +390,7 @@ def from_iterable(
def from_requires_context_result(
cls,
inner_value: 'RequiresContextResult[_ValueType, _ErrorType, _EnvType]',
) -> 'RequiresContext[Result[_ValueType, _ErrorType], _EnvType]':
) -> RequiresContext[Result[_ValueType, _ErrorType], _EnvType]:
"""
Typecasts ``RequiresContextResult`` to ``RequiresContext`` instance.

Expand All @@ -414,7 +416,7 @@ def from_requires_context_ioresult(
cls,
inner_value:
'RequiresContextIOResult[_ValueType, _ErrorType, _EnvType]',
) -> 'RequiresContext[IOResult[_ValueType, _ErrorType], _EnvType]':
) -> RequiresContext[IOResult[_ValueType, _ErrorType], _EnvType]:
"""
Typecasts ``RequiresContextIOResult`` to ``RequiresContext`` instance.

Expand All @@ -440,7 +442,7 @@ def from_requires_context_future_result(
cls,
inner_value:
'RequiresContextFutureResult[_ValueType, _ErrorType, _EnvType]',
) -> 'RequiresContext[FutureResult[_ValueType, _ErrorType], _EnvType]':
) -> RequiresContext[FutureResult[_ValueType, _ErrorType], _EnvType]:
"""
Typecasts ``RequiresContextIOResult`` to ``RequiresContext`` instance.

Expand Down
Loading