Skip to content

Feat/add better docs - #373

Merged
vinitkumar merged 4 commits into
masterfrom
feat/add-better-docs
Aug 4, 2026
Merged

Feat/add better docs#373
vinitkumar merged 4 commits into
masterfrom
feat/add-better-docs

Conversation

@vinitkumar

@vinitkumar vinitkumar commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Improve documentation and security-related dependency constraints for the JSON-to-XML converter and its Rust backend.

Enhancements:

  • Tighten comments around list handling semantics to better describe compatibility with the historical Python serializer.

Build:

  • Raise the PyO3 dependency to 0.29.1 in the Rust crate.
  • Update documentation build dependencies by pinning Requests 2.34.2 and regenerating docs requirements with pip-tools.

Documentation:

  • Clarify Rust crate public API docs around XML escaping, CDATA handling, backend selection, and error behavior.
  • Expand Json2xml class and method docstrings to document parameters, return types, and failure modes.
  • Document minimum safe versions and regeneration process for Rust PyO3 and Requests used in documentation builds.

Chores:

  • Refresh architecture documentation to reflect current accelerator and documentation dependency policies.

@sourcery-ai

sourcery-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Improves public-facing documentation and comments for the Rust JSON-to-XML accelerator and Python wrapper, clarifies serializer behavior and XML constraints, and updates security-sensitive dependency minimums (PyO3 and Requests).

File-Level Changes

Change Details Files
Clarify Rust JSON-to-XML accelerator behavior, XML invariants, and performance characteristics via doc comments.
  • Update crate-level documentation to describe the accelerator as an optional backend and explain the Python selector behavior.
  • Document the sparse escape scanning strategy and UTF-8 boundary safety for XML escaping helpers.
  • Clarify that low-level escape and CDATA helpers assume or rely on separate XML 1.0 Char validation done in Python.
  • Explain list-shape preservation and list header behavior in dict/list serializers to match Python semantics.
  • Document the dicttoxml Python entry point, its arguments, return type, and error conditions, including streaming into Python-owned bytes storage.
rust/src/lib.rs
Improve Python Json2xml wrapper documentation and error semantics.
  • Expand the Json2xml class docstring to fully describe configuration parameters and their effects on output.
  • Clarify to_xml return types, pretty-print behavior, and InvalidDataError raising conditions.
  • Add an inline comment about deferring XML parser imports to the pretty-print path.
json2xml/json2xml.py
Tighten and document security-related dependency minimums for Rust and documentation builds.
  • Raise the PyO3 dependency to 0.29.1 to avoid a known GHSA affecting list/tuple iterator reads.
  • Update docs requirements to require Requests 2.34.2 and document the pinning and regeneration process in architecture notes.
  • Add architecture documentation describing the PyO3 floor and the Requests minimum and how they are maintained with pip-tools and Dependabot.
rust/Cargo.toml
docs/requirements.txt
lat.md/architecture.md

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="json2xml/json2xml.py" line_range="47-49" />
<code_context>
     # @lat: [[behavior#Conversion output]]
     # @lat: [[behavior#Invalid XML payloads]]
     def to_xml(self) -> Any | None:
-        """
-        Convert to xml using dicttoxml.dicttoxml and then pretty print it.
+        """Serialize the configured JSON value.
+
+        :return: Pretty-printed XML text when ``pretty`` is enabled, UTF-8 encoded XML bytes
+            otherwise, or ``None`` when the configured data is ``None``.
+        :raises InvalidDataError: If serialization rejects the data or pretty-print parsing finds
</code_context>
<issue_to_address>
**suggestion:** Tighten the return type annotation to reflect the documented bytes/str/None outputs.

Since the docstring defines the outputs as pretty-printed XML text, UTF-8 XML bytes, or ``None`` when the data is ``None``, the return annotation `Any | None` should be narrowed to `bytes | str | None` to match the actual API and improve static analysis and IDE support, without breaking callers.

```suggestion
    # @lat: [[behavior#Conversion output]]
    # @lat: [[behavior#Invalid XML payloads]]
    def to_xml(self) -> bytes | str | None:
```
</issue_to_address>

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.

Comment thread json2xml/json2xml.py Outdated
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3762517) to head (09681fd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #373   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          920       920           
=========================================
  Hits           920       920           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

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

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@vinitkumar
vinitkumar merged commit 019030d into master Aug 4, 2026
59 of 62 checks passed
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.

1 participant