-
Notifications
You must be signed in to change notification settings - Fork 63
LCORE-1051: Updated Optional type in LCORE sources #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCORE-1051: Updated Optional type in LCORE sources #978
Conversation
WalkthroughType annotations across many modules were changed from union syntax ( Changes
Sequence Diagram(s)(omitted — changes are typing-only and do not introduce new multi-component control flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/models/**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/models/config.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (5)📓 Common learnings📚 Learning: 2026-01-11T16:30:41.767ZApplied to files:
📚 Learning: 2026-01-11T16:30:41.768ZApplied to files:
📚 Learning: 2026-01-11T16:30:41.767ZApplied to files:
📚 Learning: 2026-01-11T16:30:41.767ZApplied to files:
🧬 Code graph analysis (2)src/models/responses.py (1)
src/models/cache_entry.py (1)
⏰ 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). (4)
🔇 Additional comments (12)
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. Comment |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/utils/types.py (1)
64-80: Update signature to match docstring and acceptNoneinput.The signature on line 65 declares
output_message: AgentCompletionMessage(non-optional), but the docstring correctly states it should beOptional[AgentCompletionMessage]. Test cases confirm the function is called withNone(seetest_get_tool_calls_from_completion_message_when_none), and the function body defensively handles this. Update the signature to:def get_tool_calls( self, output_message: Optional[AgentCompletionMessage] ) -> list[AgentToolCall]:
🤖 Fix all issues with AI agents
In @src/utils/endpoints.py:
- Around line 538-540: The return type annotation is malformed: change the
return type from list[Optional[tuple[AnyUrl], str]] to
list[Optional[tuple[AnyUrl, str]]] (move the comma inside the tuple brackets)
and make the local variable annotation for additional_entries consistent (e.g.,
additional_entries: list[Optional[tuple[AnyUrl, str]]] = []). Update these
annotations where the function signature and the additional_entries declaration
appear so type checking passes.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/utils/checks.pysrc/utils/endpoints.pysrc/utils/transcripts.pysrc/utils/types.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: Use absolute imports for internal modules:from authentication import get_auth_dependency
Use FastAPI dependencies:from fastapi import APIRouter, HTTPException, Request, status, Depends
Use Llama Stack imports:from llama_stack_client import AsyncLlamaStackClient
Checkconstants.pyfor shared constants before defining new ones
All modules start with descriptive docstrings explaining purpose
Uselogger = logging.getLogger(__name__)pattern for module logging
Type aliases defined at module level for clarity
All functions require docstrings with brief descriptions
Complete type annotations for function parameters and return types, usingtyping_extensions.Selffor model validators
Use union types with modern syntax:str | intinstead ofUnion[str, int]
UseOptional[Type]for optional parameters
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead
Useasync deffor I/O operations and external API calls
HandleAPIConnectionErrorfrom Llama Stack in error handling
Uselogger.debug()for detailed diagnostic information
Uselogger.info()for general information about program execution
Uselogger.warning()for unexpected events or potential problems
Uselogger.error()for serious problems that prevented function execution
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with descriptive names and standard suffixes:Configuration,Error/Exception,Resolver,Interface
Use ABC for abstract base classes with@abstractmethoddecorators
Complete type annotations for all class attributes
Follow Google Python docstring conventions (https://google.github.io/styleguide/pyguide.html) with sections: Args, Returns, Raises, Attributes
Runuv run make formatto auto-format code with black and ruff before completion
Runuv run make verifyto run all linters (black, pyl...
Files:
src/utils/types.pysrc/utils/checks.pysrc/utils/transcripts.pysrc/utils/endpoints.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.768Z
Learning: Applies to **/*.py : Use union types with modern syntax: `str | int` instead of `Union[str, int]`
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.768Z
Learning: Applies to **/*.py : Use `Optional[Type]` for optional parameters
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.767Z
Learning: Applies to **/*.py : Type aliases defined at module level for clarity
📚 Learning: 2026-01-11T16:30:41.768Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.768Z
Learning: Applies to **/*.py : Use `Optional[Type]` for optional parameters
Applied to files:
src/utils/checks.pysrc/utils/endpoints.py
📚 Learning: 2026-01-11T16:30:41.768Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.768Z
Learning: Applies to **/*.py : Use union types with modern syntax: `str | int` instead of `Union[str, int]`
Applied to files:
src/utils/endpoints.py
📚 Learning: 2026-01-11T16:30:41.767Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.767Z
Learning: Applies to **/*.py : Use Llama Stack imports: `from llama_stack_client import AsyncLlamaStackClient`
Applied to files:
src/utils/endpoints.py
📚 Learning: 2026-01-11T16:30:41.768Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:30:41.768Z
Learning: Applies to **/*.py : Handle `APIConnectionError` from Llama Stack in error handling
Applied to files:
src/utils/endpoints.py
🧬 Code graph analysis (1)
src/utils/endpoints.py (3)
src/models/database/conversations.py (1)
UserConversation(11-38)src/app/database.py (1)
get_session(35-41)src/models/responses.py (2)
conversation(1442-1463)ReferencedDocument(328-338)
🪛 GitHub Actions: Integration tests
src/utils/endpoints.py
[error] 538-538: TypeError during test collection: Optional[...] expects a single type. Got (tuple[pydantic.networks.AnyUrl], <class 'str'>). Likely caused by using list[Optional[tuple[AnyUrl], str]] instead of list[Optional[tuple[AnyUrl, str]]]. This breaks Python typing in the annotation.
🪛 GitHub Actions: Type checks
src/utils/endpoints.py
[error] 538-538: mypy: Optional[...] must have exactly one type argument [valid-type].
🪛 GitHub Actions: Unit tests
src/utils/endpoints.py
[error] 538-538: Typing error in endpoint return type: Optional requires a single type. Use list[Optional[tuple[AnyUrl, str]]] instead of list[Optional[tuple[AnyUrl], str]]. This caused pytest to fail during collection.
⏰ 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: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
- GitHub Check: build-pr
- GitHub Check: E2E: server mode / ci
🔇 Additional comments (11)
src/utils/checks.py (1)
90-99: LGTM!The return type annotation update from
ModuleType | NonetoOptional[ModuleType]is consistent with the coding guidelines for optional parameters, and the docstring is properly updated to match.src/utils/transcripts.py (1)
61-61: LGTM!The parameter type annotation update to
Optional[str]aligns with the coding guidelines for optional parameters.src/utils/endpoints.py (8)
58-68: LGTM!The
Optional[UserConversation]return type correctly indicates the function may returnNonewhen no conversation is found.
71-91: LGTM!Both the return type and the local variable annotation correctly use
Optional[UserConversation]to express nullable semantics.
289-326: LGTM!The
Optional[str]annotation forconversation_idparameter and the corresponding docstring update correctly indicate the parameter's optional nature.
442-472: LGTM!The return type
Optional[tuple[Optional[AnyUrl], str]]correctly expresses that the function returns either a tuple (with potentially null URL) orNonewhen the source was already seen.
475-532: LGTM!The parameter and return type annotations using
Optionalare correct and the docstrings are properly updated to reflect the nullable semantics.
563-591: LGTM!The
Optional[dict[str, Any]]formetadata_mapand the tuple return type withOptional[AnyUrl]correctly express the nullable semantics throughout this function.
617-621: LGTM!The mixed usage is appropriate here:
Optional[dict[str, Any]]for the nullable parameter, and the union|syntax for the return type expressing two distinct list types. This aligns with the coding guidelines which recommend both patterns for their respective use cases.
724-724: LGTM!The
Optional[list[dict[str, Any]]]parameter type correctly indicatesrag_chunksmay beNone.src/utils/types.py (1)
132-133: LGTM!The
Optional[str]andOptional[float]field annotations forsourceandscorecorrectly express that these RAGChunk fields may be absent, aligning with the existing default values ofNone.
Description
LCORE-1051: Updated Optional type in LCORE sources
Type of change
Tools used to create PR
Related Tickets & Documents
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.