-
-
Notifications
You must be signed in to change notification settings - Fork 1
🐛 fix list parsing behavior and improve test cases for DecodeOptions #19
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
Conversation
|
""" WalkthroughThe changes update the logic for decoding query strings with indexed arrays, ensuring that when Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Decoder
participant Utils
Client->>Decoder: decode(query, options)
Decoder->>Decoder: parse query into temp_obj
alt parse_lists enabled and key count > list_limit
Decoder->>Decoder: set options.parse_lists = False
end
Decoder->>Utils: merge/compact temp_obj based on options
Utils-->>Decoder: return merged/compacted object
Decoder-->>Client: return decoded object
Assessment against linked issues
Possibly related PRs
Poem
""" Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/qs_codec/decode.py(1 hunks)src/qs_codec/utils/utils.py(1 hunks)tests/unit/decode_test.py(3 hunks)tests/unit/example_test.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/qs_codec/utils/utils.py (1)
src/qs_codec/models/undefined.py (1)
Undefined(6-15)
tests/unit/decode_test.py (1)
src/qs_codec/models/decode_options.py (1)
DecodeOptions(12-97)
🪛 GitHub Actions: Test
src/qs_codec/decode.py
[error] 38-38: mypy error: Argument 1 to "len" has incompatible type "Optional[dict[str, Any]]"; expected "Sized" [arg-type]
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
tests/unit/example_test.py (1)
123-123: LGTM: Test correctly reflects new sparse list compaction behavior.The test expectation has been properly updated to reflect that sparse indexed lists (
"a[1]=b&a[15]=c") are now compacted to["b", "c"]instead of preserving original indices as dictionary keys. This aligns with the improved list parsing behavior described in the PR objectives.src/qs_codec/utils/utils.py (1)
41-41: LGTM: Correctly respects the parse_lists option in merge logic.The additional condition
not options.parse_listsensures that the transformation to a dictionary with string keys only occurs when list parsing is disabled. This maintains consistency with theparse_listsconfiguration throughout the decoding process and aligns with the PR's objective to improve list parsing behavior.tests/unit/decode_test.py (3)
255-255: LGTM: Test expectation correctly updated for sparse list compaction.The expected output has been properly updated from a dictionary with string keys to a compacted list
["b", "c"], which correctly reflects the new behavior where sparse indexed lists are compacted whenparse_listsis enabled.
293-316: Excellent test coverage for parse_lists option behavior.These new test cases provide comprehensive coverage for the
parse_listsoption, verifying that:
- When
parse_lists=True: sparse lists are compacted into arrays- When
parse_lists=False: indices are preserved as dictionary keysThis ensures the option works correctly for various scenarios including missing indices and different starting positions.
538-549: LGTM: Simplified and improved sparse list compaction tests.The test parameters and expectations have been correctly updated to reflect the new sparse list compaction behavior. The simplification (removing unnecessary assertions) makes the tests cleaner while still verifying the core functionality that sparse lists are properly compacted into sequential arrays.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
==========================================
- Coverage 98.48% 98.36% -0.13%
==========================================
Files 16 16
Lines 792 794 +2
==========================================
+ Hits 780 781 +1
- Misses 12 13 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request introduces changes to the query string decoding logic in
qs_codecto improve handling of lists, particularly sparse and nested lists, and updates the corresponding unit tests to reflect the new behavior. The most significant changes include adding a safeguard for list limits, modifying the merging behavior for undefined values, and enhancing test cases for better coverage of edge cases.Changes to decoding logic:
decodeto disable list parsing when the number of elements exceeds thelist_limitspecified inDecodeOptions(src/qs_codec/decode.py).mergefunction to consider theparse_listsoption when handling undefined values, ensuring consistent behavior based on configuration (src/qs_codec/utils/utils.py).Updates to test cases:
test_parses_an_explicit_list,test_parses_a_nested_list, andtest_compacts_sparse_lists(tests/unit/decode_test.py). [1] [2] [3]tests/unit/example_test.py).Fixes #18
Summary by CodeRabbit
Bug Fixes
Tests