Skip to content

Commit 2c82735

Browse files
authored
Bump mypy to 1.10 (#1852)
1 parent 9a4818d commit 2c82735

File tree

35 files changed

+413
-432
lines changed

35 files changed

+413
-432
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ incremental in minor, bugfixes only are patches.
66
See [0Ver](https://0ver.org/).
77

88

9-
## 1.0.0 WIP
9+
## 0.23.0
10+
11+
### Features
12+
13+
- *Breaking*: Remove `success_type` and `failure_type` fields from `IOResult`,
14+
`Maybe` and `Result` types
1015

1116
### Misc
1217

13-
- *Breaking*: Remove `success_type` and `failure_type` fields from `IOResult`, `Maybe` and `Result` types
18+
- Now requires `mypy>=1.10`
19+
- Adds `[check-laws]` extra for installation
20+
1421

1522
## 0.22.0
1623

docs/pages/contrib/mypy_plugins.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ and improve type-safety of things developers commonly use.
1111
Installation
1212
------------
1313

14-
You will need to install ``mypy`` separately.
15-
It is not bundled with ``returns``.
14+
``returns`` has ``[compatible-mypy]`` extra to install the supported version.
1615

17-
To install any ``mypy`` plugin add it
16+
.. code:: bash
17+
18+
pip install 'returns[compatible-mypy]'
19+
20+
Or you can install ``mypy`` separately and check that version is supported.
21+
22+
23+
Enabling our mypy plugin
24+
------------------------
25+
26+
To install our ``mypy`` plugin add it
1827
to the ``plugins`` section of the config file (``setup.cfg`` or ``mypy.ini``):
1928

2029
.. code:: ini

poetry.lock

Lines changed: 335 additions & 374 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "returns"
3-
version = "0.22.0"
3+
version = "0.23.0"
44
description = "Make your functions return something meaningful, typed, and safe!"
55
license = "BSD-3-Clause"
66

@@ -49,13 +49,13 @@ _ = "returns.contrib.hypothesis._entrypoint"
4949
python = "^3.9"
5050

5151
typing-extensions = ">=4.0,<5.0"
52-
mypy = { version = ">=1.5,<1.6", optional = true }
52+
mypy = { version = ">=1.10,<1.11", optional = true }
5353
pytest = { version = "^8.0", optional = true }
5454
hypothesis = { version = "^6.98", optional = true }
5555

5656
[tool.poetry.group.dev.dependencies]
5757
anyio = "^4.3"
58-
trio = ">=0.24,<0.26"
58+
trio = "^0.25"
5959
attrs = "^23.2"
6060
httpx = "^0.27"
6161

returns/context/requires_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def ask(cls) -> RequiresContext[_EnvType, _EnvType]:
294294
RequiresContext[int, Dict[str, str]].ask()
295295
296296
Otherwise, your ``.ask()`` method
297-
will return ``RequiresContext[<nothing>, <nothing>]``,
297+
will return ``RequiresContext[Never, Never]``,
298298
which is unusable:
299299
300300
.. code:: python

returns/contrib/mypy/_features/kind.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def kinded_call(ctx: MethodContext) -> MypyType:
120120
Turns ``-> KindN[I, t1, t2, t3]`` into ``-> I[t1, t2, t3]``.
121121
122122
Also strips unused type arguments for ``KindN``, so:
123-
- ``KindN[IO, int, <nothing>, <nothing>]`` will be ``IO[int]``
124-
- ``KindN[Result, int, str, <nothing>]`` will be ``Result[int, str]``
123+
- ``KindN[IO, int, Never, Never]`` will be ``IO[int]``
124+
- ``KindN[Result, int, str, Never]`` will be ``Result[int, str]``
125125
126126
It also processes nested ``KindN`` with recursive strategy.
127127

returns/contrib/mypy/_typeops/inference.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
from mypy.types import CallableType, FunctionLike
99
from mypy.types import Type as MypyType
1010
from mypy.types import TypeVarId
11+
from typing_extensions import TypeAlias
1112

1213
from returns.contrib.mypy._structures.args import FuncArg
1314
from returns.contrib.mypy._structures.types import CallableContext
1415
from returns.contrib.mypy._typeops.analtype import analyze_call
1516

1617
#: Mapping of `typevar` to real type.
17-
_Constraints = Mapping[TypeVarId, MypyType]
18+
_Constraints: TypeAlias = Mapping[TypeVarId, MypyType]
1819

1920

2021
@final
@@ -81,10 +82,11 @@ def _infer_constraints(
8182
)
8283
constraints = infer_constraints_for_callable(
8384
self._fallback,
84-
[arg.type for arg in applied_args],
85-
kinds,
86-
formal_to_actual,
87-
checker.argument_infer_context(),
85+
arg_types=[arg.type for arg in applied_args],
86+
arg_kinds=kinds,
87+
arg_names=[arg.name for arg in applied_args],
88+
formal_to_actual=formal_to_actual,
89+
context=checker.argument_infer_context(),
8890
)
8991
return {
9092
constraint.type_var: constraint.target

returns/functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from typing_extensions import ParamSpec
55

6-
# Aliases:
76
_FirstType = TypeVar('_FirstType')
87
_SecondType = TypeVar('_SecondType')
98
_ThirdType = TypeVar('_ThirdType')

returns/pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from returns.primitives.exceptions import UnwrapFailedError
88

99

10+
# TODO: add overloads for specific types, so it can narrow them with `TypeIs`
1011
def is_successful(container: Unwrappable) -> bool:
1112
"""
1213
Determines if a container was successful or not.

returns/primitives/asserts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _convert(container, *, deps, backend: str):
3737
import anyio
3838

3939
return _convert(
40-
anyio.run(container.awaitable, backend=backend), # type: ignore
40+
anyio.run(container.awaitable, backend=backend),
4141
deps=deps,
4242
backend=backend,
4343
)

0 commit comments

Comments
 (0)