-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix TypeError: '>' not supported between instances of 'float' and 'NoneType'
in http
#573
Conversation
WalkthroughThe pull request introduces modifications to the host expiration logic in the Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (5)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
750dc29
to
20cbabf
Compare
TypeError: '>' not supported between instances of 'float' and 'NoneType'
in http
20cbabf
to
36a599e
Compare
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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
ably/http/http.py (1)
149-150
: The fix looks good but could be more robust.The explicit None check prevents the TypeError, but we could make the code more maintainable by:
- Adding a comment explaining why the None check is necessary
- Using a more descriptive variable name for clarity
Consider this improvement:
- # unstore saved fallback host after fallbackRetryTimeout (RSC15f) - if self.__host_expires is not None and time.time() > self.__host_expires: + # Check if fallback host has expired (RSC15f) + # host_expires can be None if no fallback host was cached or it was already cleared + fallback_host_expiry = self.__host_expires + if fallback_host_expiry is not None and time.time() > fallback_host_expiry:test/unit/http_test.py (1)
1-13
: Add test utilities for better maintainability.The tests could benefit from utility functions to reduce duplication and improve readability.
Consider adding these utilities:
import time from typing import List def get_default_ably_rest() -> AblyRest: return AblyRest(token="foo") def verify_host_list(hosts: List[str], expected_hosts: List[str], fallback_first: bool = False) -> None: """Verify that the host list contains all expected hosts in the correct order.""" assert isinstance(hosts, list), "Expected list of hosts" assert all(isinstance(host, str) for host in hosts), "All hosts should be strings" assert set(hosts) == set(expected_hosts), "All expected hosts should be present" if fallback_first: assert hosts[0] == expected_hosts[-1], "Fallback host should be first"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
ably/http/http.py
(1 hunks)test/unit/http_test.py
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: check (3.12)
- GitHub Check: check (3.11)
- GitHub Check: check (3.10)
- GitHub Check: check (3.9)
- GitHub Check: check (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.
You can check coderabbit ai suggestions regarding tests, otherwise LGTM
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.
Also, not sure why CI is failing, can you check
…time_host` is set
36a599e
to
1c22c68
Compare
Mergin as tests failures are not related to this PR |
See internal slack discussion for errors received by a client: https://ably-real-time.slack.com/archives/CURL4U2FP/p1735900004756929.
Fixes the race condition error in
http.get_rest_hosts
whenoptions.fallback_realtime_host
is set.You can see the error being reproduced in CI in this run: https://github.com/ably/ably-python/actions/runs/12692221157/job/35377048528?pr=573
Summary by CodeRabbit
Tests
Bug Fixes