Skip to content

Commit

Permalink
More type cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan Egges authored and Andreas Bergman committed Nov 27, 2024
1 parent aff22e5 commit e735813
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions 2024/returns/io_container_result.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from returns.io import IO, IOResult
from returns.result import safe
from returns.io import IOFailure, IOResult, IOSuccess


@safe
def read_file(file_path: str) -> IOResult[str, Exception]:
with open(file_path, "r") as file:
return IO(file.read())
try:
with open(file_path, "r") as file:
return IOSuccess(file.read())
except IOError as e:
return IOFailure(e)


def process_data(data: str) -> str:
Expand Down

0 comments on commit e735813

Please sign in to comment.