fix(basketball,baseball): add odds layout offsets and align customization#74
fix(basketball,baseball): add odds layout offsets and align customization#74ChuckBuilds merged 3 commits intomainfrom
Conversation
…tion Basketball: - Add odds rendering to scroll mode (render_game_card now calls _draw_dynamic_odds, matching baseball's behavior) - Apply user-configurable layout offsets to odds positioning in both switch mode (sports.py) and scroll mode (game_renderer.py) Baseball: - Add missing font customization entries: period_text, team_name, rank_text (aligns with football/basketball) - Add odds layout offset to config schema - Apply user-configurable layout offsets to odds positioning - Update x-propertyOrder to include new entries Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR adds configurable layout offsets for odds rendering across baseball and basketball scoreboard plugins, introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
plugins/baseball-scoreboard/game_renderer.py (1)
530-538: Consider aligning_get_layout_offsetbehavior withSportsCorefor consistency.Right now this parser is stricter and quieter than the one in
plugins/baseball-scoreboard/sports.py(e.g., string float handling and warning logs). Matching behavior would reduce cross-mode config surprises.Consistency-oriented refactor
def _get_layout_offset(self, element: str, axis: str, default: int = 0) -> int: """Get layout offset for a specific element and axis from config.""" try: layout_config = self.config.get('customization', {}).get('layout', {}) element_config = layout_config.get(element, {}) offset_value = element_config.get(axis, default) - return int(offset_value) if offset_value is not None else default - except (TypeError, ValueError): + if isinstance(offset_value, (int, float)): + return int(offset_value) + if isinstance(offset_value, str): + try: + return int(float(offset_value)) + except (TypeError, ValueError): + self.logger.warning( + "Invalid layout offset value for %s.%s: %r, using default %d", + element, axis, offset_value, default + ) + return default + return default + except Exception: return default🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/baseball-scoreboard/game_renderer.py` around lines 530 - 538, The _get_layout_offset method is stricter than SportsCore; update it to mirror SportsCore's behavior by accepting numeric strings (including floats), coercing them to int via int(float(value)) when needed, and emitting a warning when such coercion occurs or when a non-numeric value is ignored; keep the same default fallback on failure. Locate _get_layout_offset and the SportsCore parsing logic in plugins/baseball-scoreboard/sports.py for reference, use the instance logger (e.g., self.logger.warning) to report conversions or parse failures, and preserve the TypeError/ValueError fallback to return default.plugins/basketball-scoreboard/game_renderer.py (1)
462-470: Keep offset parsing behavior consistent withsports.py.This helper currently rejects numeric strings like
"2.0"(falls back to default), whileSportsCore._get_layout_offsetaccepts them. Aligning the coercion logic will avoid mode-to-mode config inconsistencies.Suggested refactor
def _get_layout_offset(self, element: str, axis: str, default: int = 0) -> int: """Get layout offset for a specific element and axis from config.""" try: layout_config = self.config.get('customization', {}).get('layout', {}) element_config = layout_config.get(element, {}) offset_value = element_config.get(axis, default) - return int(offset_value) if offset_value is not None else default - except (TypeError, ValueError): + if isinstance(offset_value, (int, float)): + return int(offset_value) + if isinstance(offset_value, str): + return int(float(offset_value)) + return default + except (TypeError, ValueError): return default🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/basketball-scoreboard/game_renderer.py` around lines 462 - 470, The _get_layout_offset helper currently returns default for numeric strings like "2.0"; update _get_layout_offset so it mirrors SportsCore._get_layout_offset by coercing values more flexibly: retrieve offset_value from self.config as now, then if offset_value is None return default, else try to convert to int directly, and if that fails for ValueError on strings attempt float(offset_value) then int() that result, and still catch TypeError/ValueError to return default; reference the function name _get_layout_offset and the local variables layout_config/element_config/offset_value when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/baseball-scoreboard/manifest.json`:
- Line 4: The manifest's release metadata is inconsistent: update the top entry
in the "versions" array to add the new release first and bump it to a minor
version (e.g., 1.6.0) to reflect schema additions, then set the "version" field
to the same value (ensure the top "versions" entry and the "version" field
match). Locate and update any other occurrences of the older version string in
the manifest (e.g., additional version lists or metadata entries) so all
references are consistent and reflect the new minor release.
In `@plugins/basketball-scoreboard/manifest.json`:
- Line 4: The manifest's "version" field ("version": "1.5.5") and the first
entry of the "versions" array are out of sync (top entry still "1.5.4"); update
the "versions" array by inserting a new entry for "1.5.5" at the front (most
recent first) so versions[0] equals the "version" field, and ensure any related
metadata in the new entry mirrors the format of other entries (timestamp,
changelog, etc.) so both the "version" key and versions[0] remain aligned.
---
Nitpick comments:
In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 530-538: The _get_layout_offset method is stricter than
SportsCore; update it to mirror SportsCore's behavior by accepting numeric
strings (including floats), coercing them to int via int(float(value)) when
needed, and emitting a warning when such coercion occurs or when a non-numeric
value is ignored; keep the same default fallback on failure. Locate
_get_layout_offset and the SportsCore parsing logic in
plugins/baseball-scoreboard/sports.py for reference, use the instance logger
(e.g., self.logger.warning) to report conversions or parse failures, and
preserve the TypeError/ValueError fallback to return default.
In `@plugins/basketball-scoreboard/game_renderer.py`:
- Around line 462-470: The _get_layout_offset helper currently returns default
for numeric strings like "2.0"; update _get_layout_offset so it mirrors
SportsCore._get_layout_offset by coercing values more flexibly: retrieve
offset_value from self.config as now, then if offset_value is None return
default, else try to convert to int directly, and if that fails for ValueError
on strings attempt float(offset_value) then int() that result, and still catch
TypeError/ValueError to return default; reference the function name
_get_layout_offset and the local variables
layout_config/element_config/offset_value when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 97883777-b6e5-4c34-86d9-e7b04392eb17
📒 Files selected for processing (7)
plugins/baseball-scoreboard/config_schema.jsonplugins/baseball-scoreboard/game_renderer.pyplugins/baseball-scoreboard/manifest.jsonplugins/baseball-scoreboard/sports.pyplugins/basketball-scoreboard/game_renderer.pyplugins/basketball-scoreboard/manifest.jsonplugins/basketball-scoreboard/sports.py
- Baseball manifest: bump to 1.6.0 (schema additions warrant minor), add versions array entry, update last_updated to 2026-03-30 - Basketball manifest: add missing 1.5.5 entry to versions array so versions[0] matches the version field - Both game_renderer.py _get_layout_offset: align with SportsCore pattern — handle string values via int(float(value)) and log warnings on invalid values instead of silently returning default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
render_game_cardwas missing the_draw_dynamic_oddscall). User-configurable layout offsets applied to odds positions in both display modes.period_text,team_name,rank_text) andoddslayout offset to config schema, aligning with football/basketball. Layout offsets applied to odds rendering.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores