Skip to content

Commit

Permalink
Fix various typos, re-wrap a few short lines, exchange some words (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
homeworkprod authored Apr 3, 2020
1 parent 7a1d101 commit 3029b3b
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ See [0Ver](https://0ver.org/).
for `IO` and `RequiresContext`

- Adds `flow` function, which is similar to `pipe`
- Adds `swap` coverter for `Result` and `IOResult`
- Adds `swap` converter for `Result` and `IOResult`
- Adds `squash_context` function to squash `RequiresContext` similar to `IO`

### Bugfixes
Expand Down Expand Up @@ -115,7 +115,7 @@ See [0Ver](https://0ver.org/).
- Adds `identity` function
- Adds `tap` function
- Now `pipe` allows to pipe 8 steps
- Adds `coalesce_result` and `coalesce_maybe` coverters
- Adds `coalesce_result` and `coalesce_maybe` converters

### Bugfixes

Expand Down
10 changes: 5 additions & 5 deletions docs/pages/converters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Converters
==========

We have several helpers
to convert containers from one type to another and back again.
We have several helpers to convert containers from one type to another
and back again.


Maybe and Result
Expand Down Expand Up @@ -92,7 +92,7 @@ You can use
:func:`coalesce_result <returns.converters.coalesce_result>`,
:func:`coalesce_ioresult <returns.converters.coalesce_ioresult>`,
and :func:`coalesce_maybe <returns.converters.coalesce_maybe>`
converters to covert containers to a regular value.
converters to convert containers to a regular value.

These functions accept two functions:
one for successful case, one for failing case.
Expand Down Expand Up @@ -133,8 +133,8 @@ That's how it works:
>>> assert squash_io(IO('first'), IO('second')) == IO(('first', 'second'))
>>> # => revealed type of this instance is `IO[Tuple[str, str]]`
It might be helpful if you want
to work with mutliple ``IO`` instances at the same time.
It might be helpful if you want to work with mutliple ``IO`` instances at
the same time.

This approach saves you you from multiple nested ``IO.map`` calls.
You can work with tuples instead like so:
Expand Down
4 changes: 2 additions & 2 deletions returns/_generated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
This package contains code that was "generated" via metaprogramming.
This happens, because python is not flexible enough to do most common
tasks in typed functional programming.
This happens, because Python is not flexible enough to do most tasks
common in typed functional programming.
Policy:
Expand Down
2 changes: 1 addition & 1 deletion returns/context/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
This module is quite big one, so we have split it.
This module was quite big one, so we have split it.
isort:skip_file
"""
Expand Down
30 changes: 15 additions & 15 deletions returns/context/requires_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ class RequiresContext(
The ``RequiresContext`` container.
It's main purpose is to wrap some specific function
and give tools to compose other functions around it
without the actual calling it.
and to provide tools to compose other functions around it
without actually calling it.
The ``RequiresContext`` container pass the state
The ``RequiresContext`` container passes the state
you want to share between functions.
Functions may read that state, but can't change it.
The ``RequiresContext`` container
lets us access shared immutable state within a specific context.
It can be used for lazy evaluation and typed dependency injection.
``RequiresContext`` is used with functions that never fails.
``RequiresContext`` is used with functions that never fail.
If you want to use ``RequiresContext`` with returns ``Result``
than consider using ``RequiresContextResult`` instead.
then consider using ``RequiresContextResult`` instead.
Note:
This container does not wrap ANY value. It wraps only functions.
You won't be able to supply arbitarry types!
You won't be able to supply arbitrary types!
See also:
https://dev.to/gcanti/getting-started-with-fp-ts-reader-1ie5
Expand Down Expand Up @@ -131,8 +131,8 @@ def bind(
"""
Composes a container with a function returning another container.
This is useful when you do several computations
that relies on the same context.
This is useful when you do several computations that rely on the
same context.
.. code:: python
Expand Down Expand Up @@ -208,7 +208,7 @@ def from_value(
"""
Used to return some specific value from the container.
Consider this method as a some kind of factory.
Consider this method as some kind of factory.
Passed value will be a return type.
Make sure to use :attr:`~RequiresContext.empty`
for getting the unit value.
Expand All @@ -232,11 +232,11 @@ class Context(Immutable, Generic[_EnvType]):
"""
Helpers that can be used to work with ``RequiresContext`` container.
Some of them requires explicit type to be specified.
Some of them require an explicit type to be specified.
This class contains methods that do require
This class contains methods that require
to explicitly set type annotations. Why?
Because it is impossible to figure out type without them.
Because it is impossible to figure out the type without them.
So, here's how you should use them:
Expand All @@ -246,7 +246,7 @@ class Context(Immutable, Generic[_EnvType]):
Otherwise, your ``.ask()`` method
will return ``RequiresContext[<nothing>, <nothing>]``,
which is unsable:
which is unusable:
.. code:: python
Expand All @@ -260,9 +260,9 @@ class Context(Immutable, Generic[_EnvType]):
@classmethod
def ask(cls) -> RequiresContext[_EnvType, _EnvType]:
"""
Get current context to use the depedencies.
Get current context to use the dependencies.
It is a common scenarion when you need to use the environment.
It is a common scenario when you need to use the environment.
For example, you want to do some context-related computation,
but you don't have the context instance at your disposal.
That's where ``.ask()`` becomes useful!
Expand Down
10 changes: 5 additions & 5 deletions returns/context/requires_context_io_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class RequiresContextIOResult(
This is a complex type for complex tasks!
Imporatant implementation detail:
Important implementation detail:
due it is meaning, ``RequiresContextIOResult``
cannot have ``Success`` and ``Failure`` subclasses.
Expand Down Expand Up @@ -140,7 +140,7 @@ def __call__(self, deps: _EnvType) -> IOResult[_ValueType, _ErrorType]:
>>> instance = first(False)
>>> assert instance(3.5) == IOSuccess(-3.5)
In other things, it is a regular python magic method.
In other things, it is a regular Python magic method.
"""
return self._inner_value(deps)
Expand Down Expand Up @@ -535,7 +535,7 @@ def lift(
'RequiresContextIOResult[_EnvType, _NewValueType, _ErrorType]',
]:
"""
Lifts function to be wrapped in a conatiner for better composition.
Lifts function to be wrapped in a container for better composition.
In other words, it modifies the function's
signature from: ``a -> b`` to:
Expand Down Expand Up @@ -959,9 +959,9 @@ def ask(cls) -> RequiresContextIOResult[_EnvType, _EnvType, Any]:
Similar to :meth:`returns.context.requires_context.Context.ask`,
but returns ``IOResult`` instead of a regular value.
Please, refer to the docs there to know how to use it.
Please, refer to the docs there to learn how to use it.
One important note that is worth doublicating here:
One important note that is worth duplicating here:
you might need to provide ``_EnvType`` explicitly,
so ``mypy`` will know about it statically.
Expand Down
10 changes: 5 additions & 5 deletions returns/context/requires_context_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RequiresContextResult(
- ``RequiresContext`` values and pure functions returning it
- ``Result`` and functions returning it
Imporatant implementation detail:
Important implementation detail:
due it is meaning, ``RequiresContextResult``
cannot have ``Success`` and ``Failure`` subclasses.
Expand Down Expand Up @@ -131,7 +131,7 @@ def __call__(self, deps: _EnvType) -> Result[_ValueType, _ErrorType]:
>>> instance = first(False)
>>> assert instance(3.5) == Success(-3.5)
In other things, it is a regular python magic method.
In other things, it is a regular Python magic method.
"""
return self._inner_value(deps)
Expand Down Expand Up @@ -431,7 +431,7 @@ def lift(
'RequiresContextResult[_EnvType, _NewValueType, _ErrorType]',
]:
"""
Lifts function to be wrapped in a conatiner for better composition.
Lifts function to be wrapped in a container for better composition.
In other words, it modifies the function's
signature from: ``a -> b`` to:
Expand Down Expand Up @@ -692,9 +692,9 @@ def ask(cls) -> RequiresContextResult[_EnvType, _EnvType, Any]:
Similar to :meth:`returns.context.Context.ask`,
but returns ``Result`` instead of a regular value.
Please, refer to the docs there to know how to use it.
Please, refer to the docs there to learn how to use it.
One important note that is worth doublicating here:
One important note that is worth duplicating here:
you might need to provide ``_EnvType`` explicitly,
so ``mypy`` will know about it statically.
Expand Down
6 changes: 3 additions & 3 deletions returns/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class IOResult(
This is why it has so many helper and factory methods:
- You can construct ``IOResult`` from raw value
- You can construct ``IOResult`` from raw values
with :func:`~IOSuccess` and :func:`~IOFailure` public type constructors
- You can construct ``IOResult`` from ``IO`` values
with :meth:`~IOResult.from_failed_io`
Expand Down Expand Up @@ -643,7 +643,7 @@ def from_failure(
cls, inner_value: _NewErrorType,
) -> 'IOResult[Any, _NewErrorType]':
"""
One more value to create failred unit values.
One more value to create failure unit values.
This is a part of :class:`returns.primitives.interfaces.Unitable`.
It is useful as a united way to create a new value from any container.
Expand Down Expand Up @@ -742,7 +742,7 @@ def IOSuccess( # noqa: N802
inner_value: _NewValueType,
) -> IOResult[_NewValueType, Any]:
"""
Public unit function of succeful :class:`~IOResult` container.
Public unit function of successful :class:`~IOResult` container.
.. code:: python
Expand Down
2 changes: 1 addition & 1 deletion returns/maybe.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def maybe(

def maybe(function):
"""
Decorator to covert ``None`` returning function to ``Maybe`` container.
Decorator to convert ``None``-returning function to ``Maybe`` container.
Supports both async and regular functions.
Expand Down
2 changes: 1 addition & 1 deletion returns/primitives/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Unitable(Protocol[_ValueType, _ErrorType]):
"""
Allows to create unit values from success and failure.
This is heavily ``Result`` related class.
This is a heavily ``Result``-related class.
"""

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion returns/primitives/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Immutable(object):
"""
Helper type for objects that should be immutable.
When applied, each instance becames immutable.
When applied, each instance becomes immutable.
Nothing can be added or deleted from it.
.. code:: python
Expand Down
8 changes: 4 additions & 4 deletions returns/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def from_failure(
cls, inner_value: _NewErrorType,
) -> 'Result[Any, _NewErrorType]':
"""
One more value to create failred unit values.
One more value to create failure unit values.
This is a part of :class:`returns.primitives.interfaces.Unitable`.
It is useful as a united way to create a new value from any container.
Expand All @@ -330,8 +330,8 @@ class _Failure(Result[Any, _ErrorType]):
Should not be used directly.
This is an implementation detail, please, do not use it directly.
This class only has method that are logically
dependent on the current container state: successful or failed.
This class only has methods that are logically dependent on the
current container state: successful or failed.
Use public data types instead!
"""
Expand Down Expand Up @@ -519,7 +519,7 @@ def safe(

def safe(function): # noqa: C901
"""
Decorator to covert exception throwing function to 'Result' container.
Decorator to convert exception-throwing function to 'Result' container.
Should be used with care, since it only catches 'Exception' subclasses.
It does not catch 'BaseException' subclasses.
Expand Down

0 comments on commit 3029b3b

Please sign in to comment.