Fix bytes|str narrowing in HSA2 bridge; add types-requests dev dep#245
Fix bytes|str narrowing in HSA2 bridge; add types-requests dev dep#245MrJarnould wants to merge 1 commit into
Conversation
- pyicloud/base.py: Wrap `self.session.headers.get("User-Agent", _HEADERS["User-Agent"])`
in `typing.cast(str, ...)`. `requests.Session.headers` (a `CaseInsensitiveDict`) is typed
as returning `bytes | str`, but `TrustedDeviceBridgeBootstrapper.start()` requires `str`.
In practice the header is always a str at runtime; the cast narrows the type without
changing behavior.
- requirements_test.txt: Add `types-requests>=2.32.0` so type checkers have stubs for the
`requests` library and stop emitting `untyped-import` warnings.
Resolves three Pyrefly diagnostics in base.py:
- `bad-argument-type` on the `user_agent=` argument
- `untyped-import` for `requests`
- `untyped-import` for `requests.models`
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Proposed change
Clears three Pyrefly diagnostics in
pyicloud/base.pywith no runtime behavior change:bad-argument-type— wrapsself.session.headers.get("User-Agent", _HEADERS["User-Agent"])intyping.cast(str, ...)at theTrustedDeviceBridgeBootstrapper.start()call site.requests.Session.headers(aCaseInsensitiveDict) is typed as returningbytes | str, butstart()requiresstr. In practice the header is always astrat runtime; the cast narrows the type without changing behavior.untyped-import×2 — addstypes-requests>=2.32.0torequirements_test.txtso type checkers have stubs for therequestslibrary (no longer warns onrequests/requests.modelsimports).Type of change
Additional information
Checklist
castis identity at runtime; the existing 2FA / HSA2 bridge tests exercise the call path.)🤖 Generated with Claude Code