Fix float parsing of ISO section codes like 5.10#799
Conversation
|
Warning Review limit reached
More reviews will be available in 6 minutes and 26 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR replaces gspread's automatic numeric conversion in ChangesSpreadsheet numericise fix and test coverage
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
9d6c10d to
e8d7c3e
Compare
Align spreadsheet_test with get_all_values-based read path so section codes like 5.10 stay strings instead of being float-coerced. Co-authored-by: Cursor <cursoragent@cursor.com>
Handle empty worksheets and pad short rows so section IDs are preserved as strings without IndexError or truncated dict keys.
e8d7c3e to
72ba506
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@application/utils/spreadsheet.py`:
- Around line 33-37: The code currently builds dicts from headers allowing
duplicate header names to silently collapse columns; update the logic in the
block that defines headers and records to detect duplicate header names (e.g.,
by comparing len(headers) vs len(set(headers))) and immediately raise a clear
exception (ValueError or the same error type used by read_spreadsheet()) when
duplicates are found so the existing read_spreadsheet() duplicate-header failure
path is triggered instead of producing corrupt records; do this check before the
loop that pads rows and constructs records.
- Line 37: Replace the non-strict zip call used when building row dicts so it
raises on length mismatches: update the call inside
records.append(dict(zip(headers, padded[: len(headers)]))) to pass strict=True
to zip (i.e., use headers and the sliced padded sequence with strict=True) so
Ruff B905 is satisfied; locate the expression in the same context where records,
headers, and padded are used and apply 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: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 616d00a9-f2a8-4421-8e38-fa9b57fcafd9
📒 Files selected for processing (2)
application/tests/spreadsheet_test.pyapplication/utils/spreadsheet.py
Fail fast with GSpreadException when worksheet header row contains duplicates, use zip(strict=True) after row padding, and add regression tests for the helper and read_spreadsheet integration.
What
Replace
get_all_records()withget_all_values()inread_spreadsheet()to prevent gspread'snumericise()fromconverting ISO section codes like "5.10" to float 5.1.
Why
get_all_records()internally callsnumericise()which strips trailing zeros from decimal-looking strings. Theexisting
numericise_ignoreworkaround misses column 0 and depends on gspread internals that have known bugs (see gspread#1007).get_all_values()always returns raw cell strings, so "5.10" stays "5.10". We manually construct the row dicts usingthe header row.
Testing
Existing test
test_read_spreadsheet_iso_numbersvalidates that section IDs "1.10" and "10.10" are preserved asstrings.
Closes #574
Closes #546