Skip to content

LCORE-2478: improved docstring in schema_dumper#1860

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-2478
Jun 7, 2026
Merged

LCORE-2478: improved docstring in schema_dumper#1860
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-2478

Conversation

@tisnik

@tisnik tisnik commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Description

LCORE-2478: improved docstring in schema_dumper

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-2478

Summary by CodeRabbit

  • Documentation
    • Improved documentation for the schema transformation utility to clarify how JSON schemas are converted to OpenAPI-compatible formats.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The recursive_update function's docstring in src/utils/schema_dumper.py is updated to explicitly describe how it transforms Pydantic-generated JSON-schema dictionaries into OpenAPI-compatible schemas, documenting the specific compatibility rules applied and providing clearer parameter and return type information.

Changes

Docstring Clarification

Layer / File(s) Summary
recursive_update docstring update
src/utils/schema_dumper.py
Docstring is expanded to document the transformation of Pydantic JSON-schema to OpenAPI-compatible schema, including handling of anyOf nullability conversion and exclusiveMinimum rewriting, with clarified parameter and return type documentation.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly describes the main change: an improvement to the docstring in the schema_dumper module, matching the file modification in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

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 `@src/utils/schema_dumper.py`:
- Around line 17-21: The docstring claims full recursive traversal, but the
implementation only recurses into nested dict values (and handles the specific
anyOf branch) and skips generic list-contained dicts; update the function that
contains this docstring so lists are traversed too: when encountering a list
value, iterate its items and for any item that is a dict call the same
compatibility-fix routine (preserving the existing anyOf special-case and the
dict-recursion behavior), or alternatively narrow the docstring wording to
remove "recursively" if you prefer not to change logic; focus changes around the
anyOf handling and the dict-recursion code paths so list-contained dicts get
processed the same way as plain nested dicts.
- Around line 23-31: The docstring for the function in
src/utils/schema_dumper.py that takes parameter original (dict[str, Any]) and
returns dict[str, Any] uses NumPy-style sections; update it to Google docstring
style by replacing the NumPy "Parameters:" block with an "Args:" section
(document original: dict[str, Any] — what it is and produced-by Pydantic),
convert the "Returns:" block to a single-line Google "Returns:" entry describing
the returned dict[str, Any], remove the underline blocks and trailing colons,
and add a "Raises:" section if the function may raise exceptions; keep wording
concise and follow Google conventions for parameter and return typing.
🪄 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.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cf1697b6-b89c-419a-98f3-7bd7643e054f

📥 Commits

Reviewing files that changed from the base of the PR and between 014a5ba and c37367f.

📒 Files selected for processing (1)
  • src/utils/schema_dumper.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: Pyright
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: radon
  • GitHub Check: Pylinter
  • GitHub Check: build-pr
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: spectral
  • GitHub Check: bandit
  • GitHub Check: mypy
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Llama Stack imports: Use from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules must start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
All functions must have complete type annotations for parameters and return types, use modern syntax (str | int), and include descriptive docstrings
Use snake_case with descriptive, action-oriented names for functions (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying function parameters
Use async def for I/O operations and external API calls
Use standard log levels with clear purposes: debug() for diagnostic info, info() for program execution, warning() for unexpected events, error() for serious problems
All classes must have descriptive docstrings explaining purpose and use PascalCase with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes must use ABC with @abstractmethod decorators
Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes

Files:

  • src/utils/schema_dumper.py

Comment on lines +17 to +21
Recursively walks the input mapping and applies compatibility fixes:
- converts patterns like `anyOf: [{ "type": X }, { "type": "null" }]` into
a single `"type": X` with `"nullable": True` (optional types)
- rewrites `"exclusiveMinimum"` to `"minimum"`
- otherwise preserves entries

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Docstring overstates recursive coverage.

The text says the function recursively applies transformations across the schema, but the implementation only recurses into nested dict values and does not recurse through generic list elements (except the specific anyOf branch). Please narrow the wording to match actual behavior or extend implementation to recurse into list-contained dicts.

Also applies to: 30-31

🤖 Prompt for 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.

In `@src/utils/schema_dumper.py` around lines 17 - 21, The docstring claims full
recursive traversal, but the implementation only recurses into nested dict
values (and handles the specific anyOf branch) and skips generic list-contained
dicts; update the function that contains this docstring so lists are traversed
too: when encountering a list value, iterate its items and for any item that is
a dict call the same compatibility-fix routine (preserving the existing anyOf
special-case and the dict-recursion behavior), or alternatively narrow the
docstring wording to remove "recursively" if you prefer not to change logic;
focus changes around the anyOf handling and the dict-recursion code paths so
list-contained dicts get processed the same way as plain nested dicts.

Comment on lines 23 to +31
Parameters:
----------
original (dict): The original schema dictionary to transform.
original (dict[str, Any]): Input schema dictionary that is produced by
Pydantic.

Returns:
-------
dict: A new dictionary with OpenAPI-compatible transformations applied.
dict[str, Any]: A new schema dictionary with all OpenAPI-compatible
transformations applied.

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Docstring format does not follow repository-required Google style.

This function docstring still uses NumPy-style section formatting (Parameters: + underline blocks) instead of the required Google style sections.

As per coding guidelines, “Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes.”

🤖 Prompt for 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.

In `@src/utils/schema_dumper.py` around lines 23 - 31, The docstring for the
function in src/utils/schema_dumper.py that takes parameter original (dict[str,
Any]) and returns dict[str, Any] uses NumPy-style sections; update it to Google
docstring style by replacing the NumPy "Parameters:" block with an "Args:"
section (document original: dict[str, Any] — what it is and produced-by
Pydantic), convert the "Returns:" block to a single-line Google "Returns:" entry
describing the returned dict[str, Any], remove the underline blocks and trailing
colons, and add a "Raises:" section if the function may raise exceptions; keep
wording concise and follow Google conventions for parameter and return typing.

Source: Coding guidelines

@tisnik tisnik merged commit aff9214 into lightspeed-core:main Jun 7, 2026
36 of 37 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