Skip to content

Commit

Permalink
replaced Ok.unwrap_or_else argument type of NoReturn with Any
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermalyga committed Jan 14, 2023
1 parent 7dd4b76 commit 9881bb0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion poltergeist/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def unwrap_or(self, default: DefaultT) -> T:
def unwrap_or(self, default: Any = None) -> Any:
return self.unwrap()

def unwrap_or_else(self, op: NoReturn) -> T:
def unwrap_or_else(self, op: Any) -> T:
return self.unwrap()


Expand Down
5 changes: 1 addition & 4 deletions tests/mypy/test_ok.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@
main: |
from poltergeist import Ok
instance: Ok[str]
reveal_type(instance.unwrap_or_else(lambda e: e))
out: |
main:3: note: Revealed type is "builtins.str"
main:3: error: Argument 1 to "unwrap_or_else" of "Ok" has incompatible type "Callable[[Any], Any]"; expected "NoReturn" [arg-type]
reveal_type(instance.unwrap_or_else(lambda e: e)) # N: Revealed type is "builtins.str"
5 changes: 1 addition & 4 deletions tests/mypy/test_result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,4 @@
instance: Result[str, Exception]
reveal_type(instance.unwrap_or_else(lambda e: e)) # N: Revealed type is "Union[builtins.str, builtins.Exception]"
default: str = instance.unwrap_or_else(lambda e: e) # E: Incompatible types in assignment (expression has type "Union[str, Exception]", variable has type "str") [assignment]
instance.unwrap_or_else(123)
out: |
main:5: error: Argument 1 to "unwrap_or_else" of "Ok" has incompatible type "int"; expected "NoReturn" [arg-type]
main:5: error: Argument 1 to "unwrap_or_else" of "Err" has incompatible type "int"; expected "Callable[[Exception], <nothing>]" [arg-type]
instance.unwrap_or_else(123) # E: Argument 1 to "unwrap_or_else" of "Err" has incompatible type "int"; expected "Callable[[Exception], <nothing>]" [arg-type]

0 comments on commit 9881bb0

Please sign in to comment.