-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing type hints for retry.py
#3250
Add missing type hints for retry.py
#3250
Conversation
redis/retry.py
Outdated
backoff, | ||
retries, | ||
supported_errors=(ConnectionError, TimeoutError, socket.timeout), | ||
backoff: AbstractBackoff, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should AbstractBackoff
be quoted here, when using if TYPE_CHECKING
?
Tbh, it feels cleaner to just import AbstractBackoff
always, it should not be a performance penalty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, went ahead and quoted it: 1660336
It would be nicer to quote, just to avoid an unnecessary import which would slow down module init time.
redis/retry.py
Outdated
supported_errors=(ConnectionError, TimeoutError, socket.timeout), | ||
backoff: AbstractBackoff, | ||
retries: int, | ||
supported_errors: tuple[type[Exception], ...] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We support Python 3.8, where this is not yet available. You can use Tuple[Type[Exception], ...]
and import them from typing
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, good catch!
redis/retry.py
Outdated
@@ -24,15 +34,21 @@ def __init__( | |||
self._retries = retries | |||
self._supported_errors = supported_errors | |||
|
|||
def update_supported_errors(self, specified_errors: list): | |||
def update_supported_errors( | |||
self, specified_errors: Iterable[type[Exception]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about supporting Python 3.8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gerzse Comments should be addressed. |
Thanks @max-muoto ! Getting picky now, but I run
and it complains about |
Add missing type hints in the retry.py file and related tests.
Add missing type hints in the retry.py file and related tests.
Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
Add missing type hints for the
retry.py
module.