Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alias): make the aliases Success and Failure callables to return… #36

Merged

Conversation

acostapazo
Copy link
Contributor

… typed Result class

@acostapazo acostapazo linked an issue Oct 10, 2022 that may be closed by this pull request
3 tasks
@acostapazo acostapazo self-assigned this Oct 10, 2022
@acostapazo acostapazo added the enhancement New feature or request label Oct 10, 2022
@acostapazo
Copy link
Contributor Author

Finally, the code proposed is:

def Success(value: TS = cast(TS, True)) -> Result[TS, Any]:  # type: ignore
    return Result(success=value)


def Failure(error: TF = cast(TF, Error())) -> Result[Any, TF]:  # type: ignore
    return Result(failure=error)

This helps on autocompletion and avoid typing warnings

@acostapazo acostapazo merged commit 494311e into main Oct 10, 2022
@acostapazo acostapazo deleted the 35-match-expected-type-when-using-success-and-failure-aliases branch October 10, 2022 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Match expected type when using Success and Failure aliases
3 participants