-
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.
Renamed decorator from poltergeist to catch
- Loading branch information
1 parent
f10f59a
commit 577636a
Showing
5 changed files
with
18 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from poltergeist.decorator import poltergeist | ||
from poltergeist.decorator import catch | ||
from poltergeist.result import Err, Ok, Result | ||
|
||
__all__ = ["Err", "Ok", "Result", "poltergeist"] | ||
__all__ = ["Err", "Ok", "Result", "catch"] |
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,27 +1,27 @@ | ||
- case: decorator_single_error | ||
main: | | ||
from poltergeist import poltergeist, Result | ||
from poltergeist import catch, Result | ||
@poltergeist(ValueError) | ||
@catch(ValueError) | ||
def test(a: int, b: str) -> float | None: ... | ||
reveal_type(test) # N: Revealed type is "def (a: builtins.int, b: builtins.str) -> Union[poltergeist.result.Ok[Union[builtins.float, None]], poltergeist.result.Err[builtins.ValueError]]" | ||
- case: decorator_multiple_errors | ||
skip: True # TODO: Enable this test once MyPy properly detects the return type | ||
main: | | ||
from poltergeist import poltergeist, Result | ||
from poltergeist import catch, Result | ||
@poltergeist(ValueError, TypeError) | ||
@catch(ValueError, TypeError) | ||
def test(a: int, b: str) -> float | None: ... | ||
reveal_type(test) # N: Revealed type is "def (a: builtins.int, b: builtins.str) -> Union[poltergeist.result.Ok[Union[builtins.float, None]], poltergeist.result.Err[Union[builtins.ValueError, builtins.TypeError]]]" | ||
- case: decorator_invalid_error_type | ||
main: | | ||
from poltergeist import poltergeist, Result | ||
from poltergeist import catch, Result | ||
@poltergeist(123) | ||
@catch(123) | ||
def test(a: int, b: str) -> float | None: ... | ||
out: | | ||
main:3: error: Argument 1 to "poltergeist" has incompatible type "int"; expected "Type[<nothing>]" [arg-type] | ||
main:3: error: Argument 1 to "catch" has incompatible type "int"; expected "Type[<nothing>]" [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