Skip to content

Commit

Permalink
Run pyupgrade --py39-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
kreathon committed Aug 19, 2024
1 parent f89304c commit 9c0f3d8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
from warnings import warn
from typing import (
Any,
AsyncGenerator,
Awaitable,
Callable,
Final,
Generator,
Generic,
Iterator,
Literal,
NoReturn,
Type,
TypeVar,
Union,
)
from collections.abc import AsyncGenerator, Awaitable, Generator, Iterator

from typing_extensions import TypeIs

Expand Down Expand Up @@ -52,7 +48,7 @@ def __init__(self, value: T) -> None:
self._value = value

def __repr__(self) -> str:
return "Ok({})".format(repr(self._value))
return f"Ok({repr(self._value)})"

def __eq__(self, other: Any) -> bool:
return isinstance(other, Ok) and self._value == other._value
Expand Down Expand Up @@ -251,7 +247,7 @@ def __init__(self, value: E) -> None:
self._value = value

def __repr__(self) -> str:
return "Err({})".format(repr(self._value))
return f"Err({repr(self._value)})"

def __eq__(self, other: Any) -> bool:
return isinstance(other, Err) and self._value == other._value
Expand Down Expand Up @@ -352,7 +348,7 @@ def unwrap_or_else(self, op: Callable[[E], T]) -> T:
"""
return op(self._value)

def unwrap_or_raise(self, e: Type[TBE]) -> NoReturn:
def unwrap_or_raise(self, e: type[TBE]) -> NoReturn:
"""
The contained result is ``Err``, so raise the exception with the value.
"""
Expand Down Expand Up @@ -465,7 +461,7 @@ def result(self) -> Result[Any, Any]:


def as_result(
*exceptions: Type[TBE],
*exceptions: type[TBE],
) -> Callable[[Callable[P, R]], Callable[P, Result[R, TBE]]]:
"""
Make a decorator to turn a function into one that returns a ``Result``.
Expand Down Expand Up @@ -497,7 +493,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Result[R, TBE]:


def as_async_result(
*exceptions: Type[TBE],
*exceptions: type[TBE],
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[Result[R, TBE]]]]:
"""
Make a decorator to turn an async function into one that returns a ``Result``.
Expand Down Expand Up @@ -563,7 +559,7 @@ def is_err(result: Result[T, E]) -> TypeIs[Err[E]]:
return result.is_err()


def do(gen: Generator[Result[T, E], None, None]) -> Result[T, E]:
def do(gen: Generator[Result[T, E]]) -> Result[T, E]:
"""Do notation for Result (syntactic sugar for sequence of `and_then()` calls).
Expand Down Expand Up @@ -609,7 +605,7 @@ def do(gen: Generator[Result[T, E], None, None]) -> Result[T, E]:


async def do_async(
gen: Union[Generator[Result[T, E], None, None], AsyncGenerator[Result[T, E], None]]
gen: Generator[Result[T, E]] | AsyncGenerator[Result[T, E]]
) -> Result[T, E]:
"""Async version of do. Example:
Expand Down

0 comments on commit 9c0f3d8

Please sign in to comment.