Skip to content
Merged

Fix rtd #2072

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
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-lts-latest
tools: {python: "3.11"}
tools: {python: "3.12"}
jobs:
pre_create_environment:
- asdf plugin add poetry
- asdf install poetry latest
- asdf global poetry latest
- poetry config virtualenvs.create false
- poetry self add poetry-plugin-export
- poetry export --only main --only docs --extras check_laws --format=requirements.txt --output=requirements.txt
- poetry export
--only main --only docs
--extras check_laws --extras compatible_mypy
--format=requirements.txt
--output=requirements.txt

python:
install:
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/contrib/hypothesis_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ like ``Future``, ``ReaderFutureResult``, etc
that have complex ``__init__`` signatures.
And we don't want to mess with them.

Warning::
.. warning::

Checking laws is not compatible with ``pytest-xdist``,
because we use a lot of global mutable state there.
Please, use ``returns_lawful`` marker
Expand Down
18 changes: 10 additions & 8 deletions returns/contrib/hypothesis/laws.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
@final
@dataclasses.dataclass(frozen=True)
class Settings:
"""Settings for the law tests.
"""
Settings for the law tests.

This sets the context for each generated law test, by temporarily
registering strategies for various types and passing any ``hypothesis``
Expand Down Expand Up @@ -76,11 +77,11 @@ def default_settings(container_type: type[Lawful]) -> Settings:
We use some special strategies by default, but
they can be overridden by the user if needed:

+ `TypeVar`: We need to make sure that the values generated behave
sensibly when tested for equality.
- ``TypeVar``: We need to make sure that the values generated behave
sensibly when tested for equality.

+ `collections.abc.Callable`: We need to generate pure functions, which
are not the default.
- ``collections.abc.Callable``: We need to generate pure functions,
which are not the default.

Note that this is `collections.abc.Callable`, NOT `typing.Callable`. This
is because, at runtime, `typing.get_origin(Callable[[int], str])` is
Expand Down Expand Up @@ -186,10 +187,11 @@ def pure_functions_factory(thing) -> st.SearchStrategy:


def type_vars_factory(thing: type[object]) -> StrategyFactory:
"""Strategy factory for ``TypeVar``s.
"""
Strategy factory for ``TypeVar`` objects.

We ensure that values inside strategies are self-equal. For example,
``nan`` does not work for us.
We ensure that values inside strategies are self-equal.
For example, ``float('nan')`` does not work for us.
"""
return types.resolve_TypeVar(thing).filter( # type: ignore[no-any-return]
lambda inner: inner == inner, # noqa: PLR0124, WPS312
Expand Down