Refactor: Use build_uri for building urls#116
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (7)
Walkthrough
Changesbuild_uri Refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Pull request overview
Refactors URL construction across the Trakt client to consistently use the shared build_uri(...) helper, centralizing pagination and extended query handling and reducing ad-hoc string concatenation.
Changes:
- Extend
build_uri(...)to support anextendedquery parameter in addition to pagination. - Replace manual URL/query-string building in multiple modules (
tv,users,sync,people,movies,calendar) withbuild_uri(...). - Update/expand
build_uritests to coverextendedquery behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| trakt/utils.py | Adds extended support to build_uri and updates helper documentation. |
| trakt/users.py | Switches collection and liked-lists endpoints to use build_uri. |
| trakt/tv.py | Replaces manual pagination/extended query building with build_uri and removes urlencode usage. |
| trakt/sync.py | Refactors watched/collection endpoint URI building to use build_uri with optional extended. |
| trakt/people.py | Uses build_uri for person endpoints and extended/image variants. |
| trakt/movies.py | Uses build_uri for movie endpoints and extended/image variants. |
| trakt/calendar.py | Uses build_uri for calendar URL construction with optional extended. |
| tests/test_utils.py | Updates tests to assert extended handling through build_uri. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
trakt/tv.py (1)
290-304: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
_progressmisusesbuild_urito work around missing generic query-param support.The template
uri + '?' + '&'.join(f'{key}={{{key}}}' for key in params)reconstructs a query string by hand, then relies solely onbuild_uri'sstr.formatstep to fill it in — none ofbuild_uri's actual query-building (page/limit/extended) is used here. It works, but it's harder to follow than the previousurlencode-based approach and creates a false impression thatbuild_uriis being used for its query-construction purpose.Consider keeping this on plain
urlencodeinstead of routing it throughbuild_uri:♻️ Suggested simplification
def _progress(self, progress_type, specials=False, count_specials=False, hidden=False): uri = f'{self.ext}/progress/{progress_type}' params = {} if specials: params['specials'] = 'true' if count_specials: params['count_specials'] = 'true' if hidden: params['hidden'] = 'true' if params: - uri = build_uri(uri + '?' + '&'.join( - f'{key}={{{key}}}' for key in params - ), **params) + uri += '?' + urlencode(params) data = yield uri yield data🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@trakt/tv.py` around lines 290 - 304, The _progress method is hand-building a query string and then using build_uri only for placeholder substitution, which is misleading and harder to follow. Update _progress in trakt/tv.py to build its specials/count_specials/hidden query parameters directly with urlencode-style logic instead of routing them through build_uri, and keep the existing URI construction behavior for progress_type intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@trakt/tv.py`:
- Around line 290-304: The _progress method is hand-building a query string and
then using build_uri only for placeholder substitution, which is misleading and
harder to follow. Update _progress in trakt/tv.py to build its
specials/count_specials/hidden query parameters directly with urlencode-style
logic instead of routing them through build_uri, and keep the existing URI
construction behavior for progress_type intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 75ca0352-c7f3-418c-aba9-e076321803b1
📒 Files selected for processing (8)
tests/test_utils.pytrakt/calendar.pytrakt/movies.pytrakt/people.pytrakt/sync.pytrakt/tv.pytrakt/users.pytrakt/utils.py
0da60de to
b81ff4b
Compare
Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
f8c30d8 to
acb3897
Compare
Pull request overview
Refactors URL construction across the Trakt client to consistently use the shared
build_uri(...)helper, centralizing pagination andextendedquery handling and reducing ad-hoc string concatenation.Changes:
build_uri(...)to support anextendedquery parameter in addition to pagination.tv,users,sync,people,movies,calendar) withbuild_uri(...).build_uritests to coverextendedquery behavior.Requires: