Skip to content

Commit

Permalink
Merge pull request #130 from rpdelaney/rpd-edits
Browse files Browse the repository at this point in the history
Reword motivation for deal.raises()
  • Loading branch information
orsinium committed Oct 5, 2023
2 parents da13bef + 7e8542f commit 624d9a9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions docs/basic/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ def divide(a, b):

## Motivation

Exceptions are the most implicit part of Python. Any code can raise any exception. None of the tools can say you which exceptions can be raised in some function. However, sometimes you can infer it yourself and say it to other people. And `@deal.raises` will remain you if function has raised something that you forgot to specify.

Also, it's an important decorator for autotesting. Deal won't fail tests for exceptions that were marked as allowed with `@deal.raises`.
Exceptions in Python are often implicit. Any part of the code has the potential to raise any exception, and none of the available tools can definitively identify which exceptions might be raised by a particular function. Nevertheless, sometimes you might be able to determine this yourself, and use the `@deal.raises` decorator to communicate it. The decorator also serves as a reminder if a function raises an exception that hasn't been explicitly specified. Furthermore, this decorator is valuable for auto-testing: `deal` won't flag tests as failures if exceptions are raised that have been permitted using `@deal.raises`.

0 comments on commit 624d9a9

Please sign in to comment.