Update mypy and strengthen typing for exc hooks #899
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
which is evaluated via a core loop:
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.