Skip to content

Conversation

@vinitkumar
Copy link
Owner

@vinitkumar vinitkumar commented Jan 5, 2026

Summary by Sourcery

Simplify XML ID generation and typing while improving configuration defaults and test coverage for XML conversion utilities.

Enhancements:

  • Simplify get_unique_id implementation and update ELEMENT typing to use modern union syntax.
  • Rename dict2xml_str parameter from parentIsList to parent_is_list and remove dead code in XML string conversion.
  • Avoid mutable default for xml_namespaces in dicttoxml and clarify Json2xml.to_xml return type and documentation.

Build:

  • Move testing and tooling dependencies into a new dev optional dependency group in pyproject.toml.

Documentation:

  • Document the concrete return types and behavior of Json2xml.to_xml.

Tests:

  • Update existing tests to use the new parent_is_list parameter name and adjust get_unique_id tests to validate ID format and multiple calls instead of duplicate handling internals.

Chores:

  • Add project-local Supermemory initialization documentation for the Cursor AI workflow.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 5, 2026

Reviewer's Guide

Refactors ID generation and parameter naming for JSON-to-XML conversion utilities, improves type hints and xml_namespaces handling, simplifies get_unique_id, and updates tests and project dev dependencies to match the new behavior and code quality standards.

Class diagram for updated JSON-to-XML conversion utilities

classDiagram

class Json2xml {
  -data
  -root: str
  -item_wrap: bool
  -xpath_format: bool
  +__init__(data, root, item_wrap, xpath_format)
  +to_xml() str | bytes | None
}

class dicttoxml_module {
  <<module>>
  +get_unique_id(element) str
  +dict2xml_str(item, ids, attr_type, item_func, cdata, item_name, item_wrap, parent_is_list, parent, list_headers) str
  +dicttoxml(data, custom_root, attr_type, item_name, item_wrap, item_func, cdata, xml_namespaces, list_headers, xpath_format) bytes
}

Json2xml ..> dicttoxml_module : uses
Loading

File-Level Changes

Change Details Files
Simplify get_unique_id implementation and align its tests with the new behavior and expected ID format.
  • Replace get_unique_id loop-based ID de-duplication with a direct call to make_id
  • Update tests to verify ID format and behavior via dicttoxml.get_unique_id and json2xml.dicttoxml.get_unique_id
  • Remove complex mocking- and duplicate-iteration-based tests that depended on the previous implementation details
json2xml/dicttoxml.py
tests/test_dict2xml.py
tests/test_missing_coverage.py
Standardize parameter naming for list-parent context in dict2xml_str and related call sites.
  • Rename parentIsList parameter to parent_is_list in dict2xml_str signature
  • Update all internal uses and callers (including convert_list and tests) to use parent_is_list
  • Ensure behavior for list headers and flat items remains the same using the new parameter name
json2xml/dicttoxml.py
tests/test_dict2xml.py
Improve typing and defaults in dicttoxml and Json2xml.to_xml for better code clarity and safety.
  • Change xml_namespaces parameter type from mutable default dict to Optional dict and initialize to empty dict inside the function
  • Refine ELEMENT type alias using Python 3.10+ union syntax
  • Narrow Json2xml.to_xml return type to str
bytes
Adjust project configuration to better separate runtime and development dependencies and improve test tooling.
  • Remove test-related packages from core project dependencies in pyproject.toml
  • Introduce a dev optional dependency group including pytest, coverage tools, xdist, ruff, and setuptools
  • Update pytest configuration section placement without changing options
pyproject.toml
Miscellaneous cleanup and tooling support files.
  • Remove an unused join expression in dict2xml_str that had no side effects
  • Add .cursor Supermemory command documentation file for development tooling context
  • Update uv.lock to reflect dependency and configuration changes
json2xml/dicttoxml.py
.cursor/commands/supermemory.md
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6b781f8) to head (5a0698f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #264      +/-   ##
===========================================
+ Coverage   99.69%   100.00%   +0.30%     
===========================================
  Files           3         3              
  Lines         330       323       -7     
===========================================
- Hits          329       323       -6     
+ Misses          1         0       -1     
Flag Coverage Δ
unittests 100.00% <100.00%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Renaming the dict2xml_str parameter from parentIsList to parent_is_list changes the public function signature and may break external callers using keyword arguments; consider keeping the old name as a backwards-compatible alias or accepting both via **kwargs.
  • The .cursor/commands/supermemory.md file appears to be an editor/agent configuration artifact rather than project code; consider removing it from the repository or adding it to .gitignore.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Renaming the `dict2xml_str` parameter from `parentIsList` to `parent_is_list` changes the public function signature and may break external callers using keyword arguments; consider keeping the old name as a backwards-compatible alias or accepting both via `**kwargs`.
- The `.cursor/commands/supermemory.md` file appears to be an editor/agent configuration artifact rather than project code; consider removing it from the repository or adding it to `.gitignore`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- Delete dead code (unused string join in dict2xml_str)
- Move test deps from main dependencies to [project.optional-dependencies]
- Fix mutable default argument (xml_namespaces={} -> None)
- Simplify get_unique_id (remove dead while loop logic)
- Fix vague return type (Any -> str | bytes | None)
- Fix inconsistent naming (parentIsList -> parent_is_list)
- Remove unused Union import, modernize type alias with | syntax
- Add isinstance checks in tests to satisfy type checker
uvx ty runs in isolated environment and cannot resolve pytest imports
in test files. Type checking the main module is sufficient.
@vinitkumar vinitkumar closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants