Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Oct 13, 2025

Description

LCORE-813: fixed issues found by Pyright

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

Related Tickets & Documents

  • Related Issue #LCORE-813

Summary by CodeRabbit

  • Tests
    • Strengthened unit tests with stricter typing and secure secret handling.
    • Updated tests to use path objects and refined test data structures.
    • Adjusted invocations to align with new typing and serialization expectations.
    • No changes to user-facing behavior; tests now better reflect current configuration requirements and improve reliability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

Updates a single unit test file to align with stricter typing and new helpers: adds typing annotations, switches string paths to Path objects, uses SecretStr for API keys, adjusts ByokRag initializations, and converts output paths to strings when calling generate_configuration. No public APIs or method signatures are changed.

Changes

Cohort / File(s) Summary
Tests: typing and secrets alignment
tests/unit/test_llama_stack_configuration.py
Add typing.Any annotations; use Path for db_path; replace plain API key with SecretStr; adjust ByokRag list typing; pass str(outfile) to generate_configuration; minor test data shape updates to match types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A nibble of types, a hop through Path’s lane,
Secret keys tucked where bytes can’t peek or bane.
Tests burrow deeper, tidy and neat—
ByokRag trails beneath my fleet feet.
With str(outfile), I stamp and go—
Carrot-green checks, all passing aglow! 🥕🐇

Pre-merge checks and finishing touches

✅ 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 concisely references the associated ticket and accurately summarizes that the changes address issues flagged by Pyright, which aligns with the modifications to typing, SecretStr usage, and Path conversions described in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbaf8c8 and a5996c4.

📒 Files selected for processing (1)
  • tests/unit/test_llama_stack_configuration.py (14 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed

Files:

  • tests/unit/test_llama_stack_configuration.py
tests/{unit,integration}/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard

Files:

  • tests/unit/test_llama_stack_configuration.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests

Files:

  • tests/unit/test_llama_stack_configuration.py
🧬 Code graph analysis (1)
tests/unit/test_llama_stack_configuration.py (2)
src/models/config.py (2)
  • ByokRag (554-564)
  • UserDataCollection (222-255)
src/llama_stack_configuration.py (1)
  • generate_configuration (24-49)
⏰ 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). (3)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests (azure)
  • GitHub Check: e2e_tests (ci)
🔇 Additional comments (5)
tests/unit/test_llama_stack_configuration.py (5)

5-6: LGTM! Appropriate imports for type safety.

The addition of typing.Any and pydantic.SecretStr imports supports the type annotations and security-conscious test data usage throughout the file, aligning with Pyright's strict type checking requirements.

Also applies to: 10-11


34-35: LGTM! Explicit type annotations improve type safety.

The added type annotations (dict[str, Any] for ls_config and list[ByokRag] for byok_rag) help Pyright understand the expected types and catch potential type mismatches. The pragmatic approach of annotating only where needed keeps the changes minimal and focused.

Also applies to: 58-58, 77-78, 166-167, 188-188, 203-203


82-82: LGTM! Path objects align with ByokRag model expectations.

Converting db_path values from strings to Path("tests/configuration/rag.txt") correctly aligns with the FilePath type annotation in the ByokRag model. This explicit type usage helps Pyright verify correctness and follows best practices for file path handling.

Also applies to: 87-87, 128-128, 133-133, 208-208, 213-213, 262-262, 267-267, 366-366, 371-371


312-312: LGTM! SecretStr usage maintains type safety for sensitive data.

Wrapping api_key test values with SecretStr correctly aligns with the LlamaStackConfiguration model's type expectations and demonstrates proper handling of sensitive data, even in test contexts. This ensures type consistency between tests and production code.

Also applies to: 332-332, 357-357


321-321: LGTM! Type conversions match function signature.

Converting outfile (a Path object) to a string with str(outfile) correctly matches the generate_configuration function signature, which expects output_file: str. This explicit conversion helps Pyright verify type correctness at call sites.

Also applies to: 340-340, 377-377


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.

@tisnik tisnik merged commit 8cea1a0 into lightspeed-core:main Oct 13, 2025
18 of 20 checks passed
@tisnik tisnik changed the title LCORE-831: fixed issues found by Pyright LCORE-813: fixed issues found by Pyright Oct 13, 2025
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