-
-
Notifications
You must be signed in to change notification settings - Fork 32
Feat/remove py #247
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
Feat/remove py #247
Conversation
…me handling Adds coverage for CDATA edge, numeric and namespaced keys, list header behavior, @Flat handling, Decimal typing, cdata conversion, and id attributes when ids provided.
…get_unique_id API - Accept optional ids list to avoid collisions deterministically in tests - Replace legacy type name checks with direct 'str'/'int' - Update tests to use monkeypatch for duplicate id simulation
Reviewer's GuideThis pull request bumps the project version and streamlines development dependencies, refactors the unique ID generator and XML type logic in json2xml, updates and unifies requirements across docs and root files, and simplifies existing tests while adding comprehensive coverage tests for the dicttoxml module. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #247 +/- ##
=======================================
Coverage 99.30% 99.30%
=======================================
Files 3 3
Lines 288 288
=======================================
Hits 286 286
Misses 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Hey @vinitkumar - I've reviewed your changes - here's some feedback:
- In get_xml_type, prefer using isinstance checks instead of comparing type(val).name strings for clarity and maintainability.
- Since get_unique_id now accepts a caller-provided ids list, consider using a set for faster lookup or cloning the list at the start to avoid mutating the caller’s data unexpectedly.
- The new test for get_unique_id references Mock but doesn’t import it; add the appropriate import (e.g., from unittest.mock import Mock) to prevent NameError.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In get_xml_type, prefer using isinstance checks instead of comparing type(val).__name__ strings for clarity and maintainability.
- Since get_unique_id now accepts a caller-provided ids list, consider using a set for faster lookup or cloning the list at the start to avoid mutating the caller’s data unexpectedly.
- The new test for get_unique_id references Mock but doesn’t import it; add the appropriate import (e.g., from unittest.mock import Mock) to prevent NameError.
## Individual Comments
### Comment 1
<location> `tests/test_dict2xml.py:784` </location>
<code_context>
-
- module.make_id = mock_make_id
- module.get_unique_id = patched_get_unique_id
+ unique_id = dicttoxml.get_unique_id("some_element", ids=ids)
- try:
- result = dicttoxml.get_unique_id("test")
- assert result == "test_789012"
- assert call_count == 2
- finally:
- module.make_id = original_make_id
- module.get_unique_id = original_get_unique_id
+ assert unique_id == "new_id"
+ assert make_id_mock.call_count == 2
def test_convert_with_bool_direct(self) -> None:
</code_context>
<issue_to_address>
Consider adding a test for get_unique_id when ids is None.
Adding a test for get_unique_id with ids=None will verify the function's default behavior and help prevent regressions.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
tests/test_dict2xml.py
Outdated
| unique_id = dicttoxml.get_unique_id("some_element", ids=ids) | ||
|
|
||
| try: | ||
| result = dicttoxml.get_unique_id("test") | ||
| assert result == "test_789012" | ||
| assert call_count == 2 | ||
| finally: | ||
| module.make_id = original_make_id | ||
| module.get_unique_id = original_get_unique_id | ||
| assert unique_id == "new_id" | ||
| assert make_id_mock.call_count == 2 |
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.
suggestion (testing): Consider adding a test for get_unique_id when ids is None.
Adding a test for get_unique_id with ids=None will verify the function's default behavior and help prevent regressions.
Summary by Sourcery
Bump version to 5.2.1, update dependencies for Python 3.13, enhance get_unique_id to accept custom ID lists, streamline XML type logic, and expand test coverage for dicttoxml functionality
New Features:
Bug Fixes:
Enhancements:
Build:
Documentation:
Tests: