Skip to content

Commit 6defe71

Browse files
Makes returns compatible with mypy 1.2 (#1588)
1 parent 60c23c2 commit 6defe71

File tree

114 files changed

+1292
-1048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1292
-1048
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ concurrency:
1717

1818
jobs:
1919
build:
20-
runs-on: ubuntu-latest
20+
runs-on: ubuntu-20.04
2121
strategy:
2222
fail-fast: false
2323
matrix:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ See [0Ver](https://0ver.org/).
88

99
## 0.19.1 WIP
1010

11+
### Features
12+
13+
- Now requires `mypy>=1.2`
14+
1115
### Bugfixes
1216

1317
- Fixes a problem with `do-notation` and type aliases

poetry.lock

Lines changed: 781 additions & 606 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ trio = "^0.22"
7272
attrs = "^22.1"
7373
httpx = "^0.23"
7474

75-
mypy = "^0.950"
75+
mypy = "^1.2.0"
7676
wemake-python-styleguide = "^0.17"
7777
flake8-pytest-style = "^1.6"
7878
flake8-pyi = "^22.10"
79-
# TODO: Remove this restriction when `ruamel.yaml.clib` works
80-
# correctly with Python 3.10. That lib is a dependency of `nitpick`!
81-
nitpick = { version = "^0.32", python = "<3.10" }
79+
nitpick = "^0.33.1"
8280
codespell = "^2.2"
8381
slotscheck = "^0.16.4"
8482

@@ -87,7 +85,7 @@ safety = "^2.3"
8785
pytest = "^7.2"
8886
pytest-cov = "^4.0"
8987
pytest-randomly = "^3.12"
90-
pytest-mypy-plugins = "^1.9.2"
88+
pytest-mypy-plugins = "^1.10.1"
9189
pytest-subtests = "^0.9"
9290
hypothesis = "^6.57"
9391

returns/_internal/pipeline/flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def flow(
1010
instance: _InstanceType,
1111
*functions: _PipelineStepType,
12-
) -> _ReturnType:
12+
) -> _ReturnType: # type: ignore[type-var]
1313
"""
1414
Allows to compose a value and up to multiple functions that use this value.
1515

returns/context/requires_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
@final
45-
class RequiresContext(
45+
class RequiresContext( # type: ignore[type-var]
4646
BaseContainer,
4747
SupportsKind2['RequiresContext', _ReturnType, _EnvType],
4848
reader.ReaderBased2[_ReturnType, _EnvType],
@@ -80,7 +80,7 @@ class RequiresContext(
8080
__slots__ = ()
8181

8282
#: This field has an extra 'RequiresContext' just because `mypy` needs it.
83-
_inner_value: Callable[[RequiresContext, _EnvType], _ReturnType]
83+
_inner_value: Callable[[_EnvType], _ReturnType]
8484

8585
#: A convenient placeholder to call methods created by `.from_value()`:
8686
no_args: ClassVar[NoDeps] = object()

returns/context/requires_context_future_result.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
@final
39-
class RequiresContextFutureResult(
39+
class RequiresContextFutureResult( # type: ignore[type-var]
4040
BaseContainer,
4141
SupportsKind3[
4242
'RequiresContextFutureResult', _ValueType, _ErrorType, _EnvType,
@@ -100,10 +100,7 @@ class RequiresContextFutureResult(
100100
#: Inner value of `RequiresContext`
101101
#: is just a function that returns `FutureResult`.
102102
#: This field has an extra 'RequiresContext' just because `mypy` needs it.
103-
_inner_value: Callable[
104-
[RequiresContextFutureResult, _EnvType],
105-
FutureResult[_ValueType, _ErrorType],
106-
]
103+
_inner_value: Callable[[_EnvType], FutureResult[_ValueType, _ErrorType]]
107104

108105
#: A convenient placeholder to call methods created by `.from_value()`.
109106
no_args: ClassVar[NoDeps] = object()

returns/context/requires_context_ioresult.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
# Result:
2323
_ValueType = TypeVar('_ValueType', covariant=True)
2424
_NewValueType = TypeVar('_NewValueType')
25-
_ErrorType = TypeVar('_ErrorType', covariant=True)
25+
_ErrorType = TypeVar('_ErrorType')
2626
_NewErrorType = TypeVar('_NewErrorType')
2727

2828
# Helpers:
2929
_FirstType = TypeVar('_FirstType')
3030

3131

3232
@final
33-
class RequiresContextIOResult(
33+
class RequiresContextIOResult( # type: ignore[type-var]
3434
BaseContainer,
3535
SupportsKind3['RequiresContextIOResult', _ValueType, _ErrorType, _EnvType],
3636
reader_ioresult.ReaderIOResultBasedN[_ValueType, _ErrorType, _EnvType],
@@ -107,10 +107,7 @@ class RequiresContextIOResult(
107107
#: Inner value of `RequiresContext`
108108
#: is just a function that returns `IOResult`.
109109
#: This field has an extra 'RequiresContext' just because `mypy` needs it.
110-
_inner_value: Callable[
111-
[RequiresContextIOResult, _EnvType],
112-
IOResult[_ValueType, _ErrorType],
113-
]
110+
_inner_value: Callable[[_EnvType], IOResult[_ValueType, _ErrorType]]
114111

115112
#: A convenient placeholder to call methods created by `.from_value()`.
116113
no_args: ClassVar[NoDeps] = object()

returns/context/requires_context_result.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
@final
31-
class RequiresContextResult(
31+
class RequiresContextResult( # type: ignore[type-var]
3232
BaseContainer,
3333
SupportsKind3['RequiresContextResult', _ValueType, _ErrorType, _EnvType],
3434
reader_result.ReaderResultBasedN[_ValueType, _ErrorType, _EnvType],
@@ -96,10 +96,7 @@ class RequiresContextResult(
9696
__slots__ = ()
9797

9898
#: This field has an extra 'RequiresContext' just because `mypy` needs it.
99-
_inner_value: Callable[
100-
[RequiresContextResult, _EnvType],
101-
Result[_ValueType, _ErrorType],
102-
]
99+
_inner_value: Callable[[_EnvType], Result[_ValueType, _ErrorType]]
103100

104101
#: A convenient placeholder to call methods created by `.from_value()`.
105102
no_args: ClassVar[NoDeps] = object()
@@ -337,7 +334,7 @@ def bind_context(
337334
"""
338335
return RequiresContextResult(
339336
lambda deps: self(deps).map(
340-
lambda inner: function(inner)(deps), # type: ignore
337+
lambda inner: function(inner)(deps), # type: ignore[misc]
341338
),
342339
)
343340

returns/contrib/mypy/_features/partial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Iterator, List, Optional, Tuple
22

3-
from mypy.checker import detach_callable
43
from mypy.nodes import ARG_STAR, ARG_STAR2
54
from mypy.plugin import FunctionContext
65
from mypy.types import CallableType, FunctionLike, Instance, Overloaded
@@ -17,6 +16,7 @@
1716
from returns.contrib.mypy._typeops.transform_callable import (
1817
Functions,
1918
Intermediate,
19+
detach_callable,
2020
proper_type,
2121
)
2222

0 commit comments

Comments
 (0)