repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
returns
returns/pipeline.py
.py
from typing import Any from returns._internal.pipeline.flow import flow as flow from returns._internal.pipeline.managed import managed as managed from returns._internal.pipeline.pipe import pipe as pipe from returns.interfaces.unwrappable import Unwrappable from returns.primitives.exceptions import UnwrapFailedError ...
39
1,207
returns
returns/io.py
.py
from abc import ABC from collections.abc import Callable, Generator, Iterator from functools import wraps from inspect import FrameInfo from typing import TYPE_CHECKING, Any, TypeAlias, TypeVar, final, overload from typing_extensions import ParamSpec from returns.interfaces.specific import io, ioresult from returns.p...
989
29,841
returns
returns/maybe.py
.py
from abc import ABC from collections.abc import Callable, Generator, Iterator from functools import wraps from typing import TYPE_CHECKING, Any, ClassVar, Never, Optional, TypeVar, final from typing_extensions import ParamSpec from returns.interfaces.specific.maybe import MaybeBased2 from returns.primitives.container...
492
13,755
returns
returns/functions.py
.py
from collections.abc import Callable from functools import wraps from typing import Any, Never, TypeVar from typing_extensions import ParamSpec _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _FuncParams = ParamSpec('_FuncParams') def identity(instance: _F...
163
4,009
returns
returns/result.py
.py
from abc import ABC from collections.abc import Callable, Generator, Iterator from functools import wraps from inspect import FrameInfo from typing import ( TYPE_CHECKING, Any, Never, TypeAlias, TypeVar, final, overload, ) from typing_extensions import ParamSpec from returns.interfaces.spe...
607
17,705
returns
returns/iterables.py
.py
from abc import abstractmethod from collections.abc import Callable, Iterable from typing import TypeVar, final from returns.interfaces.applicative import ApplicativeN from returns.interfaces.failable import FailableN from returns.primitives.hkt import KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = Ty...
429
12,735
returns
returns/converters.py
.py
from typing import TypeVar, overload from returns.functions import identity from returns.interfaces.bindable import BindableN from returns.maybe import Maybe, Nothing, Some from returns.pipeline import is_successful from returns.primitives.hkt import KindN, kinded from returns.result import Failure, Result, Success _...
111
3,090
returns
returns/future.py
.py
from collections.abc import ( AsyncGenerator, AsyncIterator, Awaitable, Callable, Coroutine, Generator, ) from functools import wraps from typing import Any, TypeAlias, TypeVar, final, overload from typing_extensions import ParamSpec from returns._internal.futures import _future, _future_resul...
1,631
48,479
returns
returns/curry.py
.py
from collections.abc import Callable from functools import partial as _partial from functools import wraps from inspect import BoundArguments, Signature from typing import Any, TypeAlias, TypeVar _ReturnType = TypeVar('_ReturnType') def partial( func: Callable[..., _ReturnType], *args: Any, **kwargs: Any...
191
6,466
returns
returns/trampolines.py
.py
from collections.abc import Callable from functools import wraps from typing import Generic, TypeVar, final from typing_extensions import ParamSpec _ReturnType = TypeVar('_ReturnType') _FuncParams = ParamSpec('_FuncParams') @final class Trampoline(Generic[_ReturnType]): """ Represents a wrapped function cal...
96
2,914
returns
returns/pointfree/bind_context_ioresult.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader_ioresult import ReaderIOResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.context import ReaderIOResult # no...
79
2,348
returns
returns/pointfree/bind_result.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.result import ResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.result import Result # noqa: WPS433 _FirstType = T...
60
1,783
returns
returns/pointfree/bind_context_result.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader_result import ReaderResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.context import ReaderResult # noqa: WP...
73
2,066
returns
returns/pointfree/__init__.py
.py
from returns.pointfree.alt import alt as alt from returns.pointfree.apply import apply as apply from returns.pointfree.bimap import bimap as bimap from returns.pointfree.bind import bind as bind from returns.pointfree.bind_async import bind_async as bind_async from returns.pointfree.bind_async_context_future_result imp...
44
2,164
returns
returns/pointfree/compose_result.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.ioresult import IOResultLikeN from returns.primitives.hkt import Kind3, Kinded, kinded from returns.result import Result _FirstType = TypeVar('_FirstType') _NewFirstType = TypeVar('_NewFirstType') _SecondType = TypeVar('_...
64
1,894
returns
returns/pointfree/bind_async.py
.py
from collections.abc import Awaitable, Callable from typing import TypeVar from returns.interfaces.specific.future import FutureLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeV...
64
1,826
returns
returns/pointfree/bind_context.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader import ReaderLike2, ReaderLike3 from returns.primitives.hkt import Kind2, Kind3, Kinded, kinded if TYPE_CHECKING: from returns.context import RequiresContext ...
119
3,510
returns
returns/pointfree/bind_context_future_result.py
.py
from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader_future_result import ( ReaderFutureResultLikeN, ) from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.context import ReaderFutureResult # noqa: WPS433 _F...
88
2,473
returns
returns/pointfree/alt.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.altable import AltableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') _A...
57
1,589
returns
returns/pointfree/unify.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.failable import DiverseFailableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _NewFirstType = TypeVar('_NewFirstType') _SecondType = TypeVar('_SecondType') _NewSecondType = TypeVar('_...
80
2,225
returns
returns/pointfree/bind.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.bindable import BindableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') ...
62
1,756
returns
returns/pointfree/bimap.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.bimappable import BiMappableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType1 = TypeVar('_UpdatedTy...
61
1,798
returns
returns/pointfree/bind_async_future.py
.py
from collections.abc import Awaitable, Callable from typing import TypeVar from returns.future import Future from returns.interfaces.specific.future import FutureLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar(...
66
1,839
returns
returns/pointfree/lash.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.lashable import LashableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') ...
62
1,765
returns
returns/pointfree/cond.py
.py
from collections.abc import Callable from typing import TypeVar, overload from returns.context import NoDeps from returns.interfaces.failable import DiverseFailableN, SingleFailableN from returns.methods.cond import internal_cond from returns.primitives.hkt import Kinded, KindN _ValueType = TypeVar('_ValueType') _Err...
82
2,133
returns
returns/pointfree/bind_optional.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.maybe import MaybeLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedT...
59
1,761
returns
returns/pointfree/bind_ioresult.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.ioresult import IOResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.io import IOResult # noqa: WPS433 _FirstType =...
66
1,868
returns
returns/pointfree/bind_future.py
.py
from collections.abc import Callable from typing import TypeVar from returns.future import Future from returns.interfaces.specific.future import FutureLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType...
65
1,834
returns
returns/pointfree/bind_awaitable.py
.py
from collections.abc import Awaitable, Callable from typing import TypeVar from returns.interfaces.specific.future import FutureLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeV...
64
1,784
returns
returns/pointfree/bind_io.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.io import IOLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.io import IO # noqa: WPS433 _FirstType_contra = TypeVar('_...
62
1,794
returns
returns/pointfree/bind_async_future_result.py
.py
from collections.abc import Awaitable, Callable from typing import TypeVar from returns.future import FutureResult from returns.interfaces.specific.future_result import FutureResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _T...
80
2,334
returns
returns/pointfree/apply.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.applicative import ApplicativeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedTy...
64
1,790
returns
returns/pointfree/bind_async_context_future_result.py
.py
from collections.abc import Awaitable, Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader_future_result import ( ReaderFutureResultLikeN, ) from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.context import ReaderFutureResult # noqa:...
88
2,537
returns
returns/pointfree/bind_future_result.py
.py
from collections.abc import Callable from typing import TypeVar from returns.future import FutureResult from returns.interfaces.specific.future_result import FutureResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = ...
77
2,242
returns
returns/pointfree/modify_env.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.reader import ReaderLike2, ReaderLike3 from returns.primitives.hkt import Kind2, Kind3, Kinded, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedTyp...
104
3,027
returns
returns/pointfree/map.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.mappable import MappableN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') ...
58
1,564
returns
returns/context/__init__.py
.py
"""This module was quite a big one, so we have split it.""" from returns.context.requires_context import NoDeps as NoDeps from returns.context.requires_context import Reader as Reader from returns.context.requires_context import RequiresContext as RequiresContext from returns.context.requires_context_future_result imp...
40
1,556
returns
returns/context/requires_context_ioresult.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, TypeVar, final from returns.context import NoDeps from returns.interfaces.specific import reader_ioresult from returns.io import IO, IOFailure, IOResult, IOSuccess from returns.primitive...
934
30,932
returns
returns/context/requires_context_future_result.py
.py
from __future__ import annotations from collections.abc import Awaitable, Callable from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, TypeVar, final from returns._internal.futures import _reader_future_result from returns.context import NoDeps from returns.future import Future, FutureResult from returns.inte...
1,479
48,174
returns
returns/context/requires_context_result.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, TypeVar, final from returns.context import NoDeps from returns.interfaces.specific import reader_result from returns.primitives.container import BaseContainer from returns.primitives.hkt...
650
21,158
returns
returns/context/requires_context.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, TypeVar, final from returns.functions import identity from returns.future import FutureResult from returns.interfaces.specific import reader from returns.io import IOResult from returns....
450
14,892
returns
returns/interfaces/container.py
.py
from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.interfaces import applicative, bindable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import ( Law, Law1, Law3, Lawf...
132
3,636
returns
returns/interfaces/equable.py
.py
from abc import abstractmethod from collections.abc import Sequence from typing import ClassVar, TypeVar, final from returns.primitives.laws import ( Law, Law1, Law2, Law3, Lawful, LawSpecDef, law_definition, ) _EqualType = TypeVar('_EqualType', bound='Equable') @final class _LawSpec(Law...
77
1,874
returns
returns/interfaces/unwrappable.py
.py
from abc import abstractmethod from typing import Generic, TypeVar _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _UnwrappableType = TypeVar('_UnwrappableType', bound='Unwrappable') class Unwrappable(Generic[_FirstType, _SecondType]): """ Represents containers that can unwrap and re...
51
1,602
returns
returns/interfaces/lashable.py
.py
from abc import abstractmethod from collections.abc import Callable from typing import Generic, Never, TypeVar from returns.primitives.hkt import KindN _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') _LashableType = Typ...
49
1,390
returns
returns/interfaces/altable.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Generic, Never, TypeVar, final from returns.functions import compose, identity from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import ( ...
85
2,347
returns
returns/interfaces/mappable.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Generic, Never, TypeVar, final from returns.functions import compose, identity from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import ( ...
96
2,594
returns
returns/interfaces/failable.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.interfaces import container as _container from returns.interfaces import lashable, swappable from returns.primitives.asserts import assert_equal from returns.primitives.hkt impo...
265
7,937
returns
returns/interfaces/applicative.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.functions import compose, identity from returns.interfaces import mappable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from retu...
173
4,972
returns
returns/interfaces/bimappable.py
.py
from typing import Never, TypeVar from returns.interfaces import altable, mappable _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') class BiMappableN( mappable.MappableN[_FirstType, _SecondType, _ThirdType], altable.AltableN[_FirstType, _SecondType, ...
32
817
returns
returns/interfaces/bindable.py
.py
from abc import abstractmethod from collections.abc import Callable from typing import Generic, Never, TypeVar from returns.primitives.hkt import KindN _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType') _UpdatedType = TypeVar('_UpdatedType') _BindableType = Typ...
52
1,488
returns
returns/interfaces/swappable.py
.py
from abc import abstractmethod from collections.abc import Sequence from typing import ClassVar, Never, TypeVar, final from returns.interfaces import bimappable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import ( Law, Law1, Lawf...
67
1,756
returns
returns/interfaces/specific/io.py
.py
from __future__ import annotations from abc import abstractmethod from collections.abc import Callable from typing import TYPE_CHECKING, Never, TypeVar from returns.interfaces import container, equable from returns.primitives.hkt import KindN if TYPE_CHECKING: from returns.io import IO # noqa: WPS433 _FirstTyp...
86
2,584
returns
returns/interfaces/specific/reader_future_result.py
.py
from __future__ import annotations from abc import abstractmethod from collections.abc import Awaitable, Callable, Sequence from typing import TYPE_CHECKING, ClassVar, TypeVar, final from returns.interfaces.specific import future_result, reader, reader_ioresult from returns.primitives.asserts import assert_equal from...
154
4,204
returns
returns/interfaces/specific/future_result.py
.py
""" Represents the base interfaces for types that do fear-some async operations. This type means that ``FutureResult`` can (and will!) fail with exceptions. Use this type to mark that this specific async opetaion can fail. """ from __future__ import annotations from abc import abstractmethod from collections.abc im...
110
3,356
returns
returns/interfaces/specific/maybe.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.interfaces import equable, failable, unwrappable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import...
176
5,150
returns
returns/interfaces/specific/reader_result.py
.py
from __future__ import annotations from abc import abstractmethod from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, ClassVar, TypeVar, final from returns.interfaces.specific import reader, result from returns.primitives.hkt import KindN from returns.primitives.laws import ( Law, ...
139
3,988
returns
returns/interfaces/specific/result.py
.py
""" An interface that represents a pure computation result. For impure result see :class:`returns.interfaces.specific.ioresult.IOResultLikeN` type. """ from __future__ import annotations from abc import abstractmethod from collections.abc import Callable from typing import TYPE_CHECKING, Never, TypeVar from returns...
109
2,891
returns
returns/interfaces/specific/reader_ioresult.py
.py
from __future__ import annotations from abc import abstractmethod from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, ClassVar, TypeVar, final from returns.interfaces.specific import ioresult, reader, reader_result from returns.primitives.hkt import KindN from returns.primitives.laws impo...
120
3,428
returns
returns/interfaces/specific/ioresult.py
.py
""" An interface for types that do ``IO`` and can fail. It is a base interface for both sync and async ``IO`` stacks. """ from __future__ import annotations from abc import abstractmethod from collections.abc import Callable from typing import TYPE_CHECKING, Never, TypeVar from returns.interfaces.specific import io...
110
3,247
returns
returns/interfaces/specific/future.py
.py
""" Represents the base interfaces for types that do fearless async operations. This type means that ``Future`` cannot fail. Don't use this type for async that can. Instead, use :class:`returns.interfaces.specific.future_result.FutureResultBasedN` type. """ from __future__ import annotations from abc import abstract...
148
4,601
returns
returns/interfaces/specific/reader.py
.py
""" This module is special. ``Reader`` does not produce ``ReaderLikeN`` interface as other containers. Because ``Reader`` can be used with two or three type arguments: - ``RequiresContext[value, env]`` - ``RequiresContextResult[value, error, env]`` Because the second type argument changes its meaning based on the us...
263
7,669
returns
returns/methods/__init__.py
.py
from returns.methods.cond import cond as cond from returns.methods.partition import partition as partition from returns.methods.unwrap_or_failure import ( unwrap_or_failure as unwrap_or_failure, )
6
201
returns
returns/methods/partition.py
.py
from collections.abc import Iterable from typing import TypeVar from returns.interfaces.unwrappable import Unwrappable from returns.primitives.exceptions import UnwrapFailedError _ValueType_co = TypeVar('_ValueType_co', covariant=True) _ErrorType_co = TypeVar('_ErrorType_co', covariant=True) def partition( cont...
37
1,092
returns
returns/methods/cond.py
.py
from typing import TypeVar, overload from returns.context import NoDeps from returns.interfaces.failable import DiverseFailableN, SingleFailableN from returns.primitives.hkt import KindN, kinded _ValueType = TypeVar('_ValueType') _ErrorType = TypeVar('_ErrorType') _SingleFailableKind = TypeVar('_SingleFailableKind',...
84
2,500
returns
returns/methods/unwrap_or_failure.py
.py
from typing import TypeVar from returns.interfaces.unwrappable import Unwrappable from returns.pipeline import is_successful _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') def unwrap_or_failure( container: Unwrappable[_FirstType, _SecondType], ) -> _FirstType | _SecondType: """ ...
28
728
returns
returns/contrib/hypothesis/containers.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, Any, TypeVar from hypothesis import strategies as st if TYPE_CHECKING: from returns.primitives.laws import Lawful def strategy_from_container( container_type: type[Lawful], *, use_init: bool = ...
76
2,429
returns
returns/contrib/hypothesis/_entrypoint.py
.py
""" Used to register all our types as hypothesis strategies. See: https://hypothesis.readthedocs.io/en/latest/strategies.html But, beware that we only register concrete types here, interfaces won't be registered! """ from __future__ import annotations from collections.abc import Callable, Sequence from typing impo...
65
1,831
returns
returns/contrib/hypothesis/type_resolver.py
.py
"""Make `hypothesis` resolve types to the right strategies.""" from collections.abc import Callable, Iterator, Mapping from contextlib import contextmanager from typing import TypeAlias, TypeVar from hypothesis import strategies as st from hypothesis.strategies._internal import types # noqa: PLC2701 Example_co = Ty...
76
2,485
returns
returns/contrib/hypothesis/laws.py
.py
import dataclasses import inspect from collections.abc import Callable, Iterator from contextlib import ExitStack, contextmanager from typing import Any, Self, TypeVar, final, overload import pytest from hypothesis import given from hypothesis import settings as hypothesis_settings from hypothesis import strategies as...
317
9,930
returns
returns/contrib/pytest/plugin.py
.py
import inspect import sys from collections.abc import Callable, Iterator from contextlib import ExitStack, contextmanager from functools import partial, wraps from types import FrameType, MappingProxyType from typing import TYPE_CHECKING, Any, Final, TypeAlias, TypeVar, Union, final from unittest import mock import py...
226
7,199
returns
returns/contrib/mypy/returns_plugin.py
.py
""" Custom mypy plugin to solve the temporary problem with python typing. Important: we don't do anything ugly here. We only solve problems of the current typing implementation. ``mypy`` API docs are here: https://mypy.readthedocs.io/en/latest/extending_mypy.html We use ``pytest-mypy-plugins`` to test that it works ...
129
3,821
returns
returns/contrib/mypy/_consts.py
.py
from typing import Final # Constant fullnames for typechecking # =================================== #: Used for typed ``partial`` function. TYPED_PARTIAL_FUNCTION: Final = 'returns.curry.partial' #: Used for typed ``curry`` decorator. TYPED_CURRY_FUNCTION: Final = 'returns.curry.curry' #: Used for typed ``flow`` c...
37
1,205
returns
returns/contrib/mypy/_features/partial.py
.py
from collections.abc import Iterator from itertools import starmap from typing import Final, final from mypy.nodes import ARG_STAR, ARG_STAR2 from mypy.plugin import FunctionContext from mypy.types import ( CallableType, FunctionLike, Instance, Overloaded, ProperType, TypeType, get_proper_t...
271
9,017
returns
returns/contrib/mypy/_features/pipe.py
.py
""" Typing ``pipe`` functions requires several phases. It is pretty obvious from its usage: 1. When we pass a sequence of functions we have to reduce the final callable type, it is require to match the ``callable`` protocol. And at this point we also kinda try to check that all pipeline functions do match, ...
137
4,576
returns
returns/contrib/mypy/_features/flow.py
.py
from mypy.plugin import FunctionContext from mypy.types import Type as MypyType from mypy.types import get_proper_type from returns.contrib.mypy._typeops.inference import PipelineInference def analyze(ctx: FunctionContext) -> MypyType: """ Helps to analyze ``flow`` function calls. By default, ``mypy`` c...
56
1,702
returns
returns/contrib/mypy/_features/kind.py
.py
from collections.abc import Sequence from enum import StrEnum, unique from mypy.checkmember import analyze_member_access from mypy.plugin import ( AttributeContext, FunctionContext, MethodContext, MethodSigContext, ) from mypy.typeops import bind_self from mypy.types import ( AnyType, CallableT...
175
5,234
returns
returns/contrib/mypy/_features/do_notation.py
.py
from typing import Final from mypy.maptype import map_instance_to_supertype from mypy.nodes import Expression, GeneratorExpr, TypeInfo from mypy.plugin import MethodContext from mypy.subtypes import is_subtype from mypy.typeops import make_simplified_union from mypy.types import ( AnyType, CallableType, In...
152
4,321
returns
returns/contrib/mypy/_features/curry.py
.py
from collections.abc import Iterator from itertools import groupby, product from operator import itemgetter from typing import cast, final from mypy.nodes import ARG_STAR, ARG_STAR2 from mypy.plugin import FunctionContext from mypy.types import ( AnyType, CallableType, FunctionLike, Overloaded, Typ...
205
6,688
returns
returns/contrib/mypy/_structures/args.py
.py
from itertools import starmap from typing import NamedTuple, final from mypy.nodes import ArgKind, Context, TempNode from mypy.types import CallableType from mypy.types import Type as MypyType class _FuncArgStruct(NamedTuple): """Basic struct to represent function arguments.""" name: str | None type: My...
35
1,028
returns
returns/contrib/mypy/_typeops/inference.py
.py
from collections.abc import Iterable, Mapping from typing import TypeAlias, cast, final from mypy.argmap import map_actuals_to_formals from mypy.constraints import infer_constraints_for_callable from mypy.expandtype import expand_type from mypy.nodes import ARG_POS, ArgKind from mypy.plugin import FunctionContext from...
138
4,639
returns
returns/contrib/mypy/_typeops/analtype.py
.py
from collections.abc import Sequence from types import MappingProxyType from typing import Final, Literal, overload from mypy.checkmember import analyze_member_access from mypy.nodes import ARG_NAMED, ARG_OPT from mypy.types import CallableType, FunctionLike, ProperType, get_proper_type from mypy.types import Type as ...
133
3,795
returns
returns/contrib/mypy/_typeops/transform_callable.py
.py
from types import MappingProxyType from typing import ClassVar, Final, final from mypy.nodes import ( ARG_NAMED, ARG_NAMED_OPT, ARG_OPT, ARG_POS, ARG_STAR, ARG_STAR2, ArgKind, ) from mypy.typeops import get_type_vars from mypy.types import ( AnyType, CallableType, FunctionLike, ...
279
9,476
returns
returns/contrib/mypy/_typeops/fallback.py
.py
from collections.abc import Callable from functools import wraps from typing import TypeVar from mypy.types import AnyType, TypeOfAny _CallableType = TypeVar('_CallableType', bound=Callable) def asserts_fallback_to_any(function: _CallableType) -> _CallableType: """ Falls back to ``Any`` when some ``assert ....
31
908
returns
returns/contrib/mypy/_typeops/visitor.py
.py
from collections.abc import Iterable from mypy.typeops import erase_to_bound from mypy.types import ( AnyType, CallableType, DeletedType, ErasedType, Instance, LiteralType, NoneType, Overloaded, PartialType, ProperType, TupleType, TypedDictType, TypeOfAny, TypeTy...
144
4,454
returns
returns/primitives/types.py
.py
from typing import Any, Never, Self from returns.primitives.exceptions import ImmutableStateError class Immutable: """ Helper type for objects that should be immutable. When applied, each instance becomes immutable. Nothing can be added or deleted from it. .. code:: pycon :force: >...
47
1,243
returns
returns/primitives/container.py
.py
from abc import ABC from typing import Any, TypeVar from typing_extensions import TypedDict from returns.interfaces.equable import Equable from returns.primitives.hkt import Kind1 from returns.primitives.types import Immutable _EqualType = TypeVar('_EqualType', bound=Equable) class _PickleState(TypedDict): """...
86
2,721
returns
returns/primitives/exceptions.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from returns.interfaces.unwrappable import Unwrappable # noqa: WPS433 class UnwrapFailedError(Exception): """Raised when a container can not be unwrapped into a meaningful value.""" __slots__ = ('halted_container',) ...
48
1,386
returns
returns/primitives/asserts.py
.py
def assert_equal( first, second, *, deps=None, backend: str = 'asyncio', ) -> None: """ Custom ``assert`` function to compare two any containers. The important note here is that this ``assert`` should probably used in tests. Not real application code. It will call all ``Rea...
55
1,436
returns
returns/primitives/hkt.py
.py
from collections.abc import Callable from typing import TYPE_CHECKING, Any, Generic, Never, Protocol, TypeVar from typing_extensions import TypeVarTuple _InstanceType_co = TypeVar('_InstanceType_co', covariant=True) _TypeArgType1_co = TypeVar('_TypeArgType1_co', covariant=True) _TypeArgType2_co = TypeVar('_TypeArgTyp...
278
8,587
returns
returns/primitives/tracing.py
.py
import types from collections.abc import Callable, Iterator from contextlib import AbstractContextManager, contextmanager from inspect import FrameInfo, stack from typing import TypeVar, overload from returns.result import Failure _FunctionType = TypeVar('_FunctionType', bound=Callable) @overload def collect_traces...
94
3,078
returns
returns/primitives/laws.py
.py
from collections.abc import Callable, Sequence from typing import ClassVar, Final, Generic, TypeVar, final from returns.primitives.types import Immutable _Caps = TypeVar('_Caps') _ReturnType = TypeVar('_ReturnType') _TypeArgType1 = TypeVar('_TypeArgType1') _TypeArgType2 = TypeVar('_TypeArgType2') _TypeArgType3 = Type...
148
3,717
returns
returns/primitives/reawaitable.py
.py
from collections.abc import Awaitable, Callable, Generator from functools import wraps from typing import NewType, ParamSpec, TypeVar, cast, final _ValueType = TypeVar('_ValueType') _AwaitableT = TypeVar('_AwaitableT', bound=Awaitable) _Ps = ParamSpec('_Ps') _Sentinel = NewType('_Sentinel', object) _sentinel: _Sentin...
140
3,827
returns
returns/_internal/__init__.py
.py
""" This package contains code that was "generated" via metaprogramming. This happens, because Python is not flexible enough to do most tasks common in typed functional programming. Policy: 1. We store implementations in regular ``.py`` files. 2. We store generated type annotations in ``.pyi`` files. 3. We re-export...
15
448
returns
returns/_internal/pipeline/pipe.py
.py
from returns._internal.pipeline.flow import flow def pipe(*functions): """ Allows to compose a value and up to 7 functions that use this value. We use a custom ``mypy`` plugin to make sure types are correct. Otherwise, it is currently impossible to properly type this function. Each next function...
35
1,016
returns
returns/_internal/pipeline/managed.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.ioresult import IOResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded from returns.result import Result _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_Third...
140
4,714
returns
returns/_internal/pipeline/flow.py
.py
from functools import reduce from typing import TypeVar _InstanceType = TypeVar('_InstanceType') _PipelineStepType = TypeVar('_PipelineStepType') _ReturnType = TypeVar('_ReturnType') def flow( instance: _InstanceType, *functions: _PipelineStepType, ) -> _ReturnType: # type: ignore[type-var] """ Allo...
55
1,632
returns
returns/_internal/futures/_reader_future_result.py
.py
from __future__ import annotations from collections.abc import Awaitable, Callable from typing import TYPE_CHECKING, TypeVar from returns.primitives.hkt import Kind3, dekind from returns.result import Result, Success if TYPE_CHECKING: from returns.context import RequiresContextFutureResult _ValueType_co = TypeV...
62
1,907
returns
returns/_internal/futures/_future.py
.py
from collections.abc import Awaitable, Callable from typing import TYPE_CHECKING, TypeVar from returns.io import IO from returns.primitives.hkt import Kind1, dekind if TYPE_CHECKING: from returns.future import Future _ValueType_co = TypeVar('_ValueType_co', covariant=True) _NewValueType = TypeVar('_NewValueType'...
64
2,035
returns
returns/_internal/futures/_future_result.py
.py
from __future__ import annotations from collections.abc import Awaitable, Callable from typing import TYPE_CHECKING, Any, TypeVar from returns.io import IO, IOResult from returns.primitives.hkt import Kind2, dekind from returns.result import Failure, Result, Success if TYPE_CHECKING: from returns.future import F...
184
6,869