Refactor the loop in check_authorization_status #149
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.
What have you changed?
Changed the while loop with an implicit counter to an explicit for cycle.
Also the "Checks done" and the "Max checks allowed" counter in the StopIteration exception makes no sense, because the two values will be the same (and equal to ACME_AUTH_STATUS_MAX_CHECKS) every time the exception kicks in.
I do not want to fiddle with the exception message, so made the counters reference the same value.
Why did you change it?
@mmaney suggested the refactoring of this method's cycle at #148 in his comment.
Further refactoring can be done in the following way:
However it breaks the convention of ending the method with a logger call and a return statement.
To be consistent I opted to implement a variant with less changes.
(When submitting the original PR I had difficulties finding time for doing a proper refactor, that's why #148 was a quick-n-dirty fix.)
Update:
Sorry for the noise about the force-pushes.
(FYI:
black==18.9b0
and the latestblack==19.10b0
has different rulesets about trailing commas.)