Skip to content

Commit 32226f1

Browse files
committed
Fixes mypy
1 parent bd8622b commit 32226f1

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ install:
1919
script:
2020
- poetry run flake8 returns tests docs
2121
- poetry run mypy returns tests/**/*.py
22-
- poetry run mypy returns/**/*.pyi
2322
- poetry run pytest
2423
- poetry run doc8 -q docs
2524
- poetry check

returns/either.pyi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ from typing import Any, Callable, Generic, NoReturn, TypeVar, Union
66
from typing_extensions import final
77

88
from returns.primitives.monad import Monad, NewValueType, ValueType
9-
from returns.primitives.types import MonadType
9+
10+
# There's a wierd bug with mypy when we remove this line and use import:
11+
_MonadType = TypeVar('_MonadType', bound=Union['Monad', 'Either'])
12+
1013

1114
_ErrorType = TypeVar('_ErrorType')
1215

@@ -38,7 +41,7 @@ class Left(Either[Any, _ErrorType], Monad[_ErrorType]):
3841
) -> 'Right[NewValueType]':
3942
...
4043

41-
def ebind(self, function: Callable[[_ErrorType], MonadType]) -> MonadType:
44+
def ebind(self, function: Callable[[_ErrorType], _MonadType]) -> _MonadType:
4245
...
4346

4447
def value_or(self, default_value: NewValueType) -> NewValueType:
@@ -66,8 +69,8 @@ class Right(Either[ValueType, Any], Monad[ValueType]):
6669

6770
def bind(
6871
self,
69-
function: Callable[[ValueType], MonadType],
70-
) -> MonadType:
72+
function: Callable[[ValueType], _MonadType],
73+
) -> _MonadType:
7174
...
7275

7376
def efmap(self, function) -> 'Right[ValueType]':
@@ -85,7 +88,6 @@ class Right(Either[ValueType, Any], Monad[ValueType]):
8588
def failure(self) -> NoReturn:
8689
...
8790

88-
8991
# Useful aliases for end users:
9092

9193
Result = Either

returns/maybe.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ class Some(Maybe[ValueType]):
8989

9090
def failure(self) -> NoReturn:
9191
...
92+
93+
reveal_type(Some(1).bind(lambda x: Success('s')).unwrap())

returns/primitives/types.pyi

Lines changed: 0 additions & 9 deletions
This file was deleted.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ per-file-ignores =
3131
**/*.pyi: D100, D401, X100
3232
**/*.py: D100, D401, X100
3333
# Disable some `.pyi` specific warings:
34-
**/*.pyi: D101, D102, D103, D107, Z444, Z452, Y001
34+
**/*.pyi: D101, D102, D103, D107, Z444, Z452
3535
# TODO: fix check and remove it from ignores
3636
**/*.py: Z454
3737
**/*.pyi: Z454

0 commit comments

Comments
 (0)