-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mypy and strengthen typing for exc hooks
In order to have stronger and clearer type checking enforcement on the exception hook registry, it has been refactored. Instead of all hooks being declared in terms of an exception class and/or a condition function, the hook registry stores all hooks with relevant condition functions. Exception classes are represented (internally) by building condition functions as necessary. Therefore, the hook registry is now an ordered list of the form: [(condition, hook)] which is evaluated via a core loop: for condition, hook in registry: if condition(error): return hook This is effectively what the logic was before, but it is now declared and stated as such, in a more readable manner. One of the improved inferences was achieved by declaring a separate interface method for registering an SDK-error-class hook. This indicates to mypy that any condition function will be passed an SDK error class, which allows mypy to know what attributes will (minimally) be present. --- A prereq for some of these changes to work was a mypy update (to v1.7.1). This resulted in one minor, unrelated change.
- Loading branch information
Showing
5 changed files
with
89 additions
and
49 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
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