Skip to content

Commit 439f6ed

Browse files
committed
Fill in missing type annotations in the public API
1 parent 9808f5e commit 439f6ed

13 files changed

Lines changed: 56 additions & 18 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Versions before `1.0.0` are `0Ver`-based:
55
incremental in minor, bugfixes only are patches.
66
See [0Ver](https://0ver.org/).
77

8+
## 0.31.0 WIP
9+
10+
### Features
11+
12+
- Adds missing type annotations
13+
814
## 0.30.0
915

1016
### Features

‎returns/contrib/hypothesis/laws.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def check_all_laws(
177177
)
178178

179179

180-
def pure_functions_factory(thing) -> st.SearchStrategy:
180+
def pure_functions_factory(thing: Any) -> st.SearchStrategy:
181181
"""Factory to create pure functions."""
182182
like = (
183183
(lambda: None)

‎returns/contrib/pytest/plugin.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ def __init__(self, errors_handled: _ErrorsHandled) -> None:
4242

4343
@staticmethod # noqa: WPS602
4444
def assert_equal( # noqa: WPS602
45-
first,
46-
second,
45+
first: object,
46+
second: object,
4747
*,
48-
deps=None,
48+
deps: object | None = None,
4949
backend: str = 'asyncio',
5050
) -> None:
5151
"""Can compare two containers even with extra calling and awaiting."""
5252
from returns.primitives.asserts import assert_equal # noqa: PLC0415
5353

5454
assert_equal(first, second, deps=deps, backend=backend)
5555

56-
def is_error_handled(self, container) -> bool:
56+
def is_error_handled(self, container: 'ResultLikeN[Any, Any, Any]') -> bool:
5757
"""Ensures that container has its error handled in the end."""
5858
return id(container) in self._errors_handled
5959

@@ -131,7 +131,7 @@ class _DesiredFunctionFound(BaseException): # noqa: WPS418
131131
"""Exception to raise when expected function is found."""
132132

133133

134-
def pytest_configure(config) -> None:
134+
def pytest_configure(config: pytest.Config) -> None:
135135
"""
136136
Hook to be executed on import.
137137

‎returns/methods/cond.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TypeVar, overload
1+
from typing import Final, TypeVar, overload
22

33
from returns.context import NoDeps
44
from returns.interfaces.failable import DiverseFailableN, SingleFailableN
@@ -79,6 +79,6 @@ def internal_cond(
7979
return container_type.empty
8080

8181

82-
cond = kinded(internal_cond)
82+
cond: Final = kinded(internal_cond)
8383
"""Kinded version of :func:`~internal_cond`,
8484
use it to infer real return type."""

‎returns/primitives/asserts.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def assert_equal(
2-
first,
3-
second,
2+
first: object,
3+
second: object,
44
*,
5-
deps=None,
5+
deps: object | None = None,
66
backend: str = 'asyncio',
77
) -> None:
88
"""

‎returns/primitives/container.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BaseContainer(Immutable, ABC):
2929
__slots__ = ('_inner_value',)
3030
_inner_value: Any
3131

32-
def __init__(self, inner_value) -> None:
32+
def __init__(self, inner_value: object) -> None:
3333
"""
3434
Wraps the given value in the Container.
3535

‎returns/primitives/exceptions.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING
3+
from typing import TYPE_CHECKING, Self
44

55
if TYPE_CHECKING:
66
from returns.interfaces.unwrappable import Unwrappable # noqa: WPS433
@@ -11,6 +11,8 @@ class UnwrapFailedError(Exception):
1111

1212
__slots__ = ('halted_container',)
1313

14+
halted_container: Unwrappable
15+
1416
def __init__(self, container: Unwrappable) -> None:
1517
"""
1618
Saves halted container in the inner state.
@@ -21,7 +23,7 @@ def __init__(self, container: Unwrappable) -> None:
2123
super().__init__()
2224
self.halted_container = container
2325

24-
def __reduce__(self): # noqa: WPS603
26+
def __reduce__(self) -> tuple[type[Self], tuple[Unwrappable]]: # noqa: WPS603
2527
"""Custom reduce method for pickle protocol.
2628
2729
This helps properly reconstruct the exception during unpickling.

‎returns/primitives/hkt.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def impossible(generic: T, value: V) -> T[V]:
8888

8989
if TYPE_CHECKING: # noqa: WPS604 # pragma: no cover
9090

91-
def __getattr__(self, attrname: str):
91+
def __getattr__(self, attrname: str) -> Any:
9292
"""
9393
This function is required for ``get_attribute_hook`` in mypy plugin.
9494
@@ -214,7 +214,7 @@ class Kinded(Protocol[_FunctionDefType_co]): # type: ignore
214214
def __get__(
215215
self,
216216
instance: _UpdatedType,
217-
type_,
217+
type_: type | None,
218218
) -> Callable[..., _UpdatedType]:
219219
"""Used to decorate and properly analyze method calls."""
220220

‎returns/primitives/laws.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Law(Immutable):
2828
definition: Callable
2929
"""Function used to define this law."""
3030

31-
def __init__(self, function) -> None:
31+
def __init__(self, function: Callable) -> None:
3232
"""Saves function to the inner state."""
3333
object.__setattr__(self, 'definition', function)
3434

‎returns/trampolines.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections.abc import Callable
22
from functools import wraps
3-
from typing import Generic, TypeVar, final
3+
from typing import Any, Generic, TypeVar, final
44

55
from typing_extensions import ParamSpec
66

@@ -18,6 +18,10 @@ class Trampoline(Generic[_ReturnType]):
1818

1919
__slots__ = ('args', 'func', 'kwargs')
2020

21+
func: Callable[..., _ReturnType]
22+
args: tuple[Any, ...]
23+
kwargs: dict[str, Any]
24+
2125
def __init__( # noqa: WPS451
2226
self,
2327
func: Callable[_FuncParams, _ReturnType],

0 commit comments

Comments
 (0)