Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Jan 27, 2026

Description

LCORE-889: fixed issues in config models

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

Tools used to create PR

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

Related Tickets & Documents

  • Related Issue #LCORE-889

Summary by CodeRabbit

  • Tests
    • Updated test suite with improved type-checking compliance and code quality enhancements.
    • Refined test configurations and assertions for better coverage.
    • No changes to product functionality or user-facing features.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Walkthrough

These changes modify unit test files across configuration, request, and response model tests. Primary modifications include adding pyright type-checking directives to suppress reportCallIssue warnings, reformatting constructor calls into multi-line structures, converting string file paths to Path objects in customization tests, and making explicit test assertions with optional parameters. No production code is modified.

Changes

Cohort / File(s) Summary
Config model tests with type-checking annotations
tests/unit/models/config/test_cors.py, tests/unit/models/config/test_database_configuration.py, tests/unit/models/config/test_inference_configuration.py, tests/unit/models/config/test_jwt_role_rule.py
Added inline pyright: ignore[reportCallIssue] comments to constructor invocations to suppress static type-checker warnings. Minimal formatting adjustments with no behavioral changes.
Config tests with parameter and formatting updates
tests/unit/models/config/test_customization.py, tests/unit/models/config/test_llama_stack_configuration.py
test_customization.py: Replaced string file paths with Path objects from pathlib; added assertion for system_prompt loading. test_llama_stack_configuration.py: Explicitly added optional parameters (library_client_config_path=None, api_key=None, url=None) to constructor calls and reformatted into multi-line blocks with pyright ignore comments.
Request model tests
tests/unit/models/requests/test_feedback_request.py, tests/unit/models/requests/test_query_request.py
test_feedback_request.py: Added sentiment argument to FeedbackRequest constructions; added assertions for non-None categories. test_query_request.py: Reformatted constructor calls into multi-line format with pyright ignore annotations.
Response model tests
tests/unit/models/responses/test_rag_chunk.py, tests/unit/models/responses/test_successful_responses.py
test_rag_chunk.py: Added inline pyright ignore comments and reformatted multi-line arguments. test_successful_responses.py: Added ConfigDict import from pydantic; replaced dict-based model_config annotation with ConfigDict in test class; added pyright ignore markers to response constructor calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'LCORE-889: fixed issues in config models' accurately describes the main change—fixing issues in configuration model tests through formatting, type annotations, and parameter adjustments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI agents
In `@tests/unit/models/responses/test_rag_chunk.py`:
- Line 11: The RAGChunk Pydantic model uses Pydantic v1-style Field positional
defaults causing type-checker ignores; update the RAGChunk field definitions in
the RAGChunk model (in src/utils/types.py) to use explicit default= for optional
fields (e.g., change Field(None, ...) to Field(default=None, ...)) for both
source and score (and any other optional Field uses) so the fields are correctly
recognized as optional by Pydantic v2 and you can remove the pyright ignore
comments in the related tests.
🧹 Nitpick comments (2)
tests/unit/models/requests/test_feedback_request.py (1)

196-198: Consider using consistent pyright ignore format.

The comment # pyright: ignore Should be list differs from the format used elsewhere in this PR (# pyright: ignore[reportCallIssue]). For consistency, consider specifying the error code.

Suggested format
-                categories="invalid_type",  # pyright: ignore Should be list, not string
+                categories="invalid_type",  # pyright: ignore[reportArgumentType] - Should be list, not string
tests/unit/models/config/test_llama_stack_configuration.py (1)

32-40: Consider using # type: ignore[call-arg] for consistency with other test files.

The # pyright: ignore[reportCallIssue] comments are added to suppress type checker warnings. However, other test files in this PR (e.g., test_successful_responses.py) use # type: ignore[call-arg] which is more portable across type checkers (mypy, pyright, etc.).

def test_constructor_with_content_only(self) -> None:
"""Test RAGChunk constructor with content only."""
chunk = RAGChunk(content="Sample content")
chunk = RAGChunk(content="Sample content") # pyright: ignore[reportCallIssue]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check Pydantic version
find . -name "*.toml" -o -name "*requirements*.txt" | head -20 | xargs rg "pydantic" -l

Repository: lightspeed-core/lightspeed-stack

Length of output: 107


🏁 Script executed:

# First, find where RAGChunk is defined
fd -t f "*.py" | xargs rg -l "class RAGChunk"

Repository: lightspeed-core/lightspeed-stack

Length of output: 395


🏁 Script executed:

# Examine the test file to understand the pattern
wc -l tests/unit/models/responses/test_rag_chunk.py

Repository: lightspeed-core/lightspeed-stack

Length of output: 125


🏁 Script executed:

# Check Pydantic version
rg "pydantic" requirements.hashes.wheel.txt | head -5

Repository: lightspeed-core/lightspeed-stack

Length of output: 146


🏁 Script executed:

# Examine RAGChunk model definition
cat -n src/utils/types.py | head -100

Repository: lightspeed-core/lightspeed-stack

Length of output: 4008


🏁 Script executed:

# Examine the test file around the specified lines
cat -n tests/unit/models/responses/test_rag_chunk.py

Repository: lightspeed-core/lightspeed-stack

Length of output: 5522


🏁 Script executed:

# Find RAGChunk class definition
rg -n "class RAGChunk" src/utils/types.py -A 20

Repository: lightspeed-core/lightspeed-stack

Length of output: 962


🏁 Script executed:

# Also check if there are other files defining RAGChunk
fd -type f -name "*.py" | xargs rg -l "class RAGChunk"

Repository: lightspeed-core/lightspeed-stack

Length of output: 282


🏁 Script executed:

# Check if there are other Pydantic models in the codebase using proper v2 syntax
rg "Field\(default" src/ --type py -A 1 | head -20

Repository: lightspeed-core/lightspeed-stack

Length of output: 373


🏁 Script executed:

# Check the learnings file mentioned to understand expected patterns
cat -n CLAUDE.md 2>/dev/null || echo "CLAUDE.md not found"

Repository: lightspeed-core/lightspeed-stack

Length of output: 10041


🏁 Script executed:

# Verify if Field(None, ...) works at runtime in Pydantic v2 by checking other models
rg "Field\(None" src/ --type py

Repository: lightspeed-core/lightspeed-stack

Length of output: 376


🏁 Script executed:

# Verify by checking Pydantic documentation and seeing if Field(None, ...) works in v2
# Let's check if there are any tests that might show runtime behavior
rg -n "RAGChunk" tests/ -B 2 -A 2 | head -40

Repository: lightspeed-core/lightspeed-stack

Length of output: 3324


🏁 Script executed:

# Check if any of the constructed chunks are actually used/asserted properly
rg -n "assert.*score.*None" tests/unit/models/responses/test_rag_chunk.py

Repository: lightspeed-core/lightspeed-stack

Length of output: 189


Update RAGChunk model to use proper Pydantic v2 syntax for optional fields.

The systematic pyright: ignore[reportCallIssue] comments across multiple tests indicate the RAGChunk model uses outdated Pydantic v1 Field syntax. In Pydantic v2, the first positional argument to Field() is not the default value.

The model definition in src/utils/types.py (lines 142-143) currently uses:

source: Optional[str] = Field(None, description="Source document or URL")
score: Optional[float] = Field(None, description="Relevance score")

This should be updated to:

source: Optional[str] = Field(default=None, description="Source document or URL")
score: Optional[float] = Field(default=None, description="Relevance score")

This is why tests that provide all three parameters (lines 96-98, 116-118) don't require ignore comments—they satisfy the incorrectly-inferred required parameters. Fix the model definition rather than suppressing type-checker warnings in tests.

Also applies to: 42-42, 49-51, 59-61, 65-67, 71-73, 78-78, 110-110

🤖 Prompt for AI Agents
In `@tests/unit/models/responses/test_rag_chunk.py` at line 11, The RAGChunk
Pydantic model uses Pydantic v1-style Field positional defaults causing
type-checker ignores; update the RAGChunk field definitions in the RAGChunk
model (in src/utils/types.py) to use explicit default= for optional fields
(e.g., change Field(None, ...) to Field(default=None, ...)) for both source and
score (and any other optional Field uses) so the fields are correctly recognized
as optional by Pydantic v2 and you can remove the pyright ignore comments in the
related tests.

@tisnik tisnik merged commit 02c5cfc into lightspeed-core:main Jan 27, 2026
22 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