Skip to content

Commit

Permalink
update NoReturn to Never mypy 1.11.0 (#1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaBars authored Jul 25, 2024
1 parent e6fc70b commit 610939a
Show file tree
Hide file tree
Showing 24 changed files with 109 additions and 108 deletions.
6 changes: 3 additions & 3 deletions docs/pages/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ for example, can have one, two or three possible types. See the example below:

.. code:: python
>>> from typing import NoReturn
>>> from typing_extensions import Never
>>> from returns.interfaces.mappable import (
... MappableN, Mappable1, Mappable2, Mappable3,
... )
>>> one_type: MappableN[int, NoReturn, NoReturn]
>>> two_types: MappableN[int, str, NoReturn]
>>> one_type: MappableN[int, Never, Never]
>>> two_types: MappableN[int, str, Never]
>>> three_types: MappableN[int, str, bool]
>>> # We have a shortcut for each amount of arguments to reduce the boilerplate
Expand Down
6 changes: 3 additions & 3 deletions returns/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import wraps
from typing import Any, Callable, NoReturn, TypeVar
from typing import Any, Callable, TypeVar

from typing_extensions import ParamSpec
from typing_extensions import Never, ParamSpec

_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
Expand Down Expand Up @@ -105,7 +105,7 @@ def decorator(argument_to_return: _FirstType) -> None:
return decorator


def raise_exception(exception: Exception) -> NoReturn:
def raise_exception(exception: Exception) -> Never:
"""
Helper function to raise exceptions as a function.
Expand Down
14 changes: 4 additions & 10 deletions returns/interfaces/altable.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from abc import abstractmethod
from typing import (
Callable,
ClassVar,
Generic,
NoReturn,
Sequence,
TypeVar,
final,
)
from typing import Callable, ClassVar, Generic, Sequence, TypeVar, final

from typing_extensions import Never

from returns.functions import compose, identity
from returns.primitives.asserts import assert_equal
Expand Down Expand Up @@ -85,7 +79,7 @@ def alt(


#: Type alias for kinds with two type arguments.
Altable2 = AltableN[_FirstType, _SecondType, NoReturn]
Altable2 = AltableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Altable3 = AltableN[_FirstType, _SecondType, _ThirdType]
8 changes: 5 additions & 3 deletions returns/interfaces/applicative.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from abc import abstractmethod
from typing import Callable, ClassVar, NoReturn, Sequence, Type, TypeVar, final
from typing import Callable, ClassVar, Sequence, Type, TypeVar, final

from typing_extensions import Never

from returns.functions import compose, identity
from returns.interfaces import mappable
Expand Down Expand Up @@ -162,10 +164,10 @@ def from_value(


#: Type alias for kinds with one type argument.
Applicative1 = ApplicativeN[_FirstType, NoReturn, NoReturn]
Applicative1 = ApplicativeN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
Applicative2 = ApplicativeN[_FirstType, _SecondType, NoReturn]
Applicative2 = ApplicativeN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Applicative3 = ApplicativeN[_FirstType, _SecondType, _ThirdType]
6 changes: 4 additions & 2 deletions returns/interfaces/bimappable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import NoReturn, TypeVar
from typing import TypeVar

from typing_extensions import Never

from returns.interfaces import altable, mappable

Expand All @@ -25,7 +27,7 @@ class BiMappableN(


#: Type alias for kinds with two type arguments.
BiMappable2 = BiMappableN[_FirstType, _SecondType, NoReturn]
BiMappable2 = BiMappableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
BiMappable3 = BiMappableN[_FirstType, _SecondType, _ThirdType]
8 changes: 5 additions & 3 deletions returns/interfaces/bindable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from abc import abstractmethod
from typing import Callable, Generic, NoReturn, TypeVar
from typing import Callable, Generic, TypeVar

from typing_extensions import Never

from returns.primitives.hkt import KindN

Expand Down Expand Up @@ -41,10 +43,10 @@ def bind(


#: Type alias for kinds with one type argument.
Bindable1 = BindableN[_FirstType, NoReturn, NoReturn]
Bindable1 = BindableN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
Bindable2 = BindableN[_FirstType, _SecondType, NoReturn]
Bindable2 = BindableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Bindable3 = BindableN[_FirstType, _SecondType, _ThirdType]
8 changes: 5 additions & 3 deletions returns/interfaces/container.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Callable, ClassVar, NoReturn, Sequence, TypeVar, final
from typing import Callable, ClassVar, Sequence, TypeVar, final

from typing_extensions import Never

from returns.interfaces import applicative, bindable
from returns.primitives.asserts import assert_equal
Expand Down Expand Up @@ -121,10 +123,10 @@ class ContainerN(


#: Type alias for kinds with one type argument.
Container1 = ContainerN[_FirstType, NoReturn, NoReturn]
Container1 = ContainerN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
Container2 = ContainerN[_FirstType, _SecondType, NoReturn]
Container2 = ContainerN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Container3 = ContainerN[_FirstType, _SecondType, _ThirdType]
10 changes: 6 additions & 4 deletions returns/interfaces/failable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from abc import abstractmethod
from typing import Callable, ClassVar, NoReturn, Sequence, Type, TypeVar, final
from typing import Callable, ClassVar, Sequence, Type, TypeVar, final

from typing_extensions import Never

from returns.interfaces import container as _container
from returns.interfaces import lashable, swappable
Expand Down Expand Up @@ -73,7 +75,7 @@ class FailableN(


#: Type alias for kinds with two type arguments.
Failable2 = FailableN[_FirstType, _SecondType, NoReturn]
Failable2 = FailableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Failable3 = FailableN[_FirstType, _SecondType, _ThirdType]
Expand Down Expand Up @@ -154,7 +156,7 @@ def empty(


#: Type alias for kinds with two types arguments.
SingleFailable2 = SingleFailableN[_FirstType, _SecondType, NoReturn]
SingleFailable2 = SingleFailableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
SingleFailable3 = SingleFailableN[_FirstType, _SecondType, _ThirdType]
Expand Down Expand Up @@ -258,7 +260,7 @@ def from_failure(


#: Type alias for kinds with two type arguments.
DiverseFailable2 = DiverseFailableN[_FirstType, _SecondType, NoReturn]
DiverseFailable2 = DiverseFailableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
DiverseFailable3 = DiverseFailableN[_FirstType, _SecondType, _ThirdType]
6 changes: 4 additions & 2 deletions returns/interfaces/lashable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from abc import abstractmethod
from typing import Callable, Generic, NoReturn, TypeVar
from typing import Callable, Generic, TypeVar

from typing_extensions import Never

from returns.primitives.hkt import KindN

Expand Down Expand Up @@ -41,7 +43,7 @@ def lash(


#: Type alias for kinds with two type arguments.
Lashable2 = LashableN[_FirstType, _SecondType, NoReturn]
Lashable2 = LashableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Lashable3 = LashableN[_FirstType, _SecondType, _ThirdType]
16 changes: 5 additions & 11 deletions returns/interfaces/mappable.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from abc import abstractmethod
from typing import (
Callable,
ClassVar,
Generic,
NoReturn,
Sequence,
TypeVar,
final,
)
from typing import Callable, ClassVar, Generic, Sequence, TypeVar, final

from typing_extensions import Never

from returns.functions import compose, identity
from returns.primitives.asserts import assert_equal
Expand Down Expand Up @@ -93,10 +87,10 @@ def map(


#: Type alias for kinds with one type argument.
Mappable1 = MappableN[_FirstType, NoReturn, NoReturn]
Mappable1 = MappableN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
Mappable2 = MappableN[_FirstType, _SecondType, NoReturn]
Mappable2 = MappableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
Mappable3 = MappableN[_FirstType, _SecondType, _ThirdType]
15 changes: 8 additions & 7 deletions returns/interfaces/specific/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
Callable,
Generator,
Generic,
NoReturn,
TypeVar,
)

from typing_extensions import Never

from returns.interfaces.specific import io
from returns.primitives.hkt import KindN

Expand Down Expand Up @@ -88,10 +89,10 @@ def from_future(


#: Type alias for kinds with one type argument.
FutureLike1 = FutureLikeN[_FirstType, NoReturn, NoReturn]
FutureLike1 = FutureLikeN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
FutureLike2 = FutureLikeN[_FirstType, _SecondType, NoReturn]
FutureLike2 = FutureLikeN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
FutureLike3 = FutureLikeN[_FirstType, _SecondType, _ThirdType]
Expand Down Expand Up @@ -120,10 +121,10 @@ async def awaitable(


#: Type alias for kinds with one type argument.
AsyncFuture1 = AwaitableFutureN[_FirstType, NoReturn, NoReturn]
AsyncFuture1 = AwaitableFutureN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
AsyncFuture2 = AwaitableFutureN[_FirstType, _SecondType, NoReturn]
AsyncFuture2 = AwaitableFutureN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
AsyncFuture3 = AwaitableFutureN[_FirstType, _SecondType, _ThirdType]
Expand All @@ -143,10 +144,10 @@ class FutureBasedN(


#: Type alias for kinds with one type argument.
FutureBased1 = FutureBasedN[_FirstType, NoReturn, NoReturn]
FutureBased1 = FutureBasedN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
FutureBased2 = FutureBasedN[_FirstType, _SecondType, NoReturn]
FutureBased2 = FutureBasedN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
FutureBased3 = FutureBasedN[_FirstType, _SecondType, _ThirdType]
8 changes: 5 additions & 3 deletions returns/interfaces/specific/future_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from __future__ import annotations

from abc import abstractmethod
from typing import TYPE_CHECKING, Awaitable, Callable, NoReturn, TypeVar
from typing import TYPE_CHECKING, Awaitable, Callable, TypeVar

from typing_extensions import Never

from returns.interfaces.specific import future, ioresult
from returns.primitives.hkt import KindN
Expand Down Expand Up @@ -80,7 +82,7 @@ def from_future_result(


#: Type alias for kinds with two type arguments.
FutureResultLike2 = FutureResultLikeN[_FirstType, _SecondType, NoReturn]
FutureResultLike2 = FutureResultLikeN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
FutureResultLike3 = FutureResultLikeN[_FirstType, _SecondType, _ThirdType]
Expand All @@ -101,7 +103,7 @@ class FutureResultBasedN(


#: Type alias for kinds with two type arguments.
FutureResultBased2 = FutureResultBasedN[_FirstType, _SecondType, NoReturn]
FutureResultBased2 = FutureResultBasedN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
FutureResultBased3 = FutureResultBasedN[_FirstType, _SecondType, _ThirdType]
12 changes: 7 additions & 5 deletions returns/interfaces/specific/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

from abc import abstractmethod
from typing import TYPE_CHECKING, Callable, NoReturn, TypeVar
from typing import TYPE_CHECKING, Callable, TypeVar

from typing_extensions import Never

from returns.interfaces import container, equable
from returns.primitives.hkt import KindN
Expand Down Expand Up @@ -46,10 +48,10 @@ def from_io(


#: Type alias for kinds with one type argument.
IOLike1 = IOLikeN[_FirstType, NoReturn, NoReturn]
IOLike1 = IOLikeN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
IOLike2 = IOLikeN[_FirstType, _SecondType, NoReturn]
IOLike2 = IOLikeN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
IOLike3 = IOLikeN[_FirstType, _SecondType, _ThirdType]
Expand All @@ -75,10 +77,10 @@ class IOBasedN(


#: Type alias for kinds with one type argument.
IOBased1 = IOBasedN[_FirstType, NoReturn, NoReturn]
IOBased1 = IOBasedN[_FirstType, Never, Never]

#: Type alias for kinds with two type arguments.
IOBased2 = IOBasedN[_FirstType, _SecondType, NoReturn]
IOBased2 = IOBasedN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
IOBased3 = IOBasedN[_FirstType, _SecondType, _ThirdType]
8 changes: 5 additions & 3 deletions returns/interfaces/specific/ioresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from __future__ import annotations

from abc import abstractmethod
from typing import TYPE_CHECKING, Callable, NoReturn, TypeVar
from typing import TYPE_CHECKING, Callable, TypeVar

from typing_extensions import Never

from returns.interfaces.specific import io, result
from returns.primitives.hkt import KindN
Expand Down Expand Up @@ -74,7 +76,7 @@ def from_failed_io(


#: Type alias for kinds with two type arguments.
IOResultLike2 = IOResultLikeN[_FirstType, _SecondType, NoReturn]
IOResultLike2 = IOResultLikeN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
IOResultLike3 = IOResultLikeN[_FirstType, _SecondType, _ThirdType]
Expand Down Expand Up @@ -102,7 +104,7 @@ class IOResultBasedN(


#: Type alias for kinds with two type arguments.
IOResultBased2 = IOResultBasedN[_FirstType, _SecondType, NoReturn]
IOResultBased2 = IOResultBasedN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
IOResultBased3 = IOResultBasedN[_FirstType, _SecondType, _ThirdType]
Loading

0 comments on commit 610939a

Please sign in to comment.