Skip to content

Commit

Permalink
Opportunistically depend on typing extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhammerl committed Jul 30, 2024
1 parent 6014436 commit 8e059b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Result is a simple, type annotated Result type for Python 3.6+ inspired by [Rust

The idea is that a result value can be either `Ok(value)` or `Err(error)`, with a way to differentiate between the two. `Ok` and `Err` are both classes wrapping an arbitrary value. `Result[T, E]` is a generic type alias for `typing.Union[Ok[T], Err[E]]`.

Requires Python 3.6 or higher!
Requires Python 3.8 or higher!

NB: If you are using a Python version lower than 3.10, you will have to install `typing_extensions`!


### Caveats
Expand Down
14 changes: 13 additions & 1 deletion resultify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from time import sleep
from functools import wraps
from typing import Any, Generic, ParamSpec, TypeVar, Union, Type, Callable

try:
from typing import Any, Generic, ParamSpec, TypeVar, Union, Type, Callable
except ImportError:
from typing_extensions import (
Any,
Generic,
ParamSpec,
TypeVar,
Union,
Type,
Callable,
)

T = TypeVar("T", bound=Any) # Success type
E = TypeVar("E", bound=Exception) # Error type
Expand Down

0 comments on commit 8e059b0

Please sign in to comment.