-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed unnecessary generic parameters from Ok and Err. WIP
- Loading branch information
1 parent
f148059
commit 7dd4b76
Showing
6 changed files
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
- case: err_generic | ||
main: | | ||
from poltergeist import Err | ||
instance: Err[str, Exception] = Err(123) # E: Argument 1 to "Err" has incompatible type "int"; expected "Exception" [arg-type] | ||
other: Err[str, int] # E: Type argument "int" of "Err" must be a subtype of "BaseException" [type-var] | ||
instance: Err[Exception] = Err(123) # E: Argument 1 to "Err" has incompatible type "int"; expected "Exception" [arg-type] | ||
other: Err[int] # E: Type argument "int" of "Err" must be a subtype of "BaseException" [type-var] | ||
- case: err_err | ||
main: | | ||
from poltergeist import Err | ||
instance: Err[str, Exception] | ||
instance: Err[Exception] | ||
reveal_type(instance.err()) # N: Revealed type is "builtins.Exception" | ||
- case: err_unwrap | ||
main: | | ||
from poltergeist import Err | ||
instance: Err[str, Exception] | ||
instance: Err[Exception] | ||
reveal_type(instance.unwrap()) # N: Revealed type is "<nothing>" | ||
- case: err_unwrap_or | ||
main: | | ||
from poltergeist import Err | ||
instance: Err[str, Exception] | ||
instance: Err[Exception] | ||
reveal_type(instance.unwrap_or()) # N: Revealed type is "None" | ||
reveal_type(instance.unwrap_or(123)) # N: Revealed type is "builtins.int" | ||
reveal_type(instance.unwrap_or("abc")) # N: Revealed type is "builtins.str" | ||
- case: err_unwrap_or_else | ||
main: | | ||
from poltergeist import Err | ||
instance: Err[str, Exception] | ||
instance: Err[Exception] | ||
reveal_type(instance.unwrap_or_else(lambda e: e)) # N: Revealed type is "builtins.Exception" | ||
instance.unwrap_or_else(123) # E: Argument 1 to "unwrap_or_else" of "Err" has incompatible type "int"; expected "Callable[[Exception], <nothing>]" [arg-type] | ||
default: str = instance.unwrap_or_else(lambda e: e) # E: Incompatible types in assignment (expression has type "Exception", variable has type "str") [assignment] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
- case: ok_generic | ||
main: | | ||
from poltergeist import Ok | ||
instance: Ok[str, Exception] = Ok(123) # E: Argument 1 to "Ok" has incompatible type "int"; expected "str" [arg-type] | ||
other: Ok[str, int] # E: Type argument "int" of "Ok" must be a subtype of "BaseException" [type-var] | ||
instance: Ok[str] = Ok(123) # E: Argument 1 to "Ok" has incompatible type "int"; expected "str" [arg-type] | ||
- case: ok_err | ||
main: | | ||
from poltergeist import Ok | ||
instance: Ok[str, Exception] | ||
instance: Ok[str] | ||
reveal_type(instance.err()) # N: Revealed type is "None" | ||
- case: ok_unwrap | ||
main: | | ||
from poltergeist import Ok | ||
instance: Ok[str, Exception] | ||
instance: Ok[str] | ||
reveal_type(instance.unwrap()) # N: Revealed type is "builtins.str" | ||
- case: ok_unwrap_or | ||
main: | | ||
from poltergeist import Ok | ||
instance: Ok[str, Exception] | ||
instance: Ok[str] | ||
reveal_type(instance.unwrap_or()) # N: Revealed type is "builtins.str" | ||
reveal_type(instance.unwrap_or(123)) # N: Revealed type is "builtins.str" | ||
reveal_type(instance.unwrap_or("abc")) # N: Revealed type is "builtins.str" | ||
- case: ok_unwrap_or_else | ||
main: | | ||
from poltergeist import Ok | ||
instance: Ok[str, Exception] | ||
reveal_type(instance.unwrap_or_else(lambda e: e)) # N: Revealed type is "builtins.str" | ||
instance.unwrap_or_else(123) # E: Argument 1 to "unwrap_or_else" of "Ok" has incompatible type "int"; expected "Callable[[Exception], <nothing>]" [arg-type] | ||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters