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

Simplify generics #2

Merged
merged 2 commits into from
Jan 14, 2023
Merged

Simplify generics #2

merged 2 commits into from
Jan 14, 2023

Conversation

alexandermalyga
Copy link
Owner

No description provided.

@@ -31,13 +31,13 @@ def unwrap_or(self, default: DefaultT) -> T:
def unwrap_or(self, default: Any = None) -> Any:
return self.unwrap()

def unwrap_or_else(self, op: Callable[[E], DefaultT]) -> T:
def unwrap_or_else(self, op: Any) -> T:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Any as the argument's type works, but breaks type inference when using Result.unwrap_or_else() with lambdas. I tried to use NoReturn instead, but MyPy was complaining. So I think this is the best approach for now.

@alexandermalyga alexandermalyga merged commit 1ebd311 into main Jan 14, 2023
@alexandermalyga alexandermalyga deleted the simplify-generics branch January 17, 2023 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant