Replies: 1 comment
-
Hi Arnold, sorry for the delayed response. What you're doing sounds like a perfectly normal way to use Result. I just tried out something like this, based on your description and it works without any errors. from dataclasses import dataclass
@dataclass
class SomeDTO:
some_result: Result[list[int], str]
def test_dto():
dto = SomeDTO(Ok([1,2,3]))
assert dto.some_result.expect("Should be Ok") == [1,2,3] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good day,
Was tinkering with Result the last day, looks very interesting.
However, I was trying to use the Result type as a dataclass item, where Ok will be a list and Err a str. But I couldn't get it to work..
Is this possible and / or a good idea. Or should I do it the opposite and wrap the complete dataclass in the Ok variant?
Context: I have a DTO with a cmd (enum), timestamp, related cmd data and if possible a return Result type.
Thanks,
Arnold
Beta Was this translation helpful? Give feedback.
All reactions