LCORE-814: fixed issues found by Pyright#661
Conversation
WalkthroughTests in tests/unit/utils/test_endpoints.py were expanded to include stricter runtime assertions and type checks involving ReferencedDocument. Multiple test scenarios for create_referenced_documents were augmented to validate instance types, presence, and specific field values across different input variations and edge cases. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/unit/utils/test_endpoints.py (2)
873-880: Remove redundant runtime type assertions.The added assertions checking for non-None values and
isinstance(ReferencedDocument)are redundant and don't address the root cause of Pyright issues:
Redundant None checks: After asserting
len(result) == 2, checkingresult[0] is not Noneis unnecessary - if a list has length 2, both elements exist.Implementation testing vs. contract testing: The
isinstancechecks verify runtime types rather than testing behavior. Ifcreate_referenced_documentsis properly typed to returnlist[ReferencedDocument], Pyright should trust that without runtime checks.Runtime checks don't fix static analysis: These assertions only execute during tests and don't help Pyright understand the types. To fix Pyright issues, you need proper type hints and type guards in the implementation, not runtime assertions in tests.
Instead, focus the tests on behavioral aspects (correct URLs, titles, deduplication, filtering) which are already being tested by the subsequent assertions.
If Pyright is complaining about potential None values or wrong types in the
create_referenced_documentsfunction, the fix should be in that function's type hints or implementation, not in the tests.Also applies to: 901-908, 922-927, 942-947, 965-972, 984-991
115-117: Add explanatory comment to Pyright ignores on QueryRequestThe
# pyright: ignore[reportCallIssue]onQueryRequest(...)is necessary because Pydantic’s BaseModel uses a dynamic__init__signature that Pyright can’t statically infer. Keep the ignore and append a note, e.g.:# pyright: ignore[reportCallIssue] # Pydantic BaseModel dynamic __init__ signature
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/unit/utils/test_endpoints.py(10 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/utils/test_endpoints.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/utils/test_endpoints.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/utils/test_endpoints.py
🧬 Code graph analysis (1)
tests/unit/utils/test_endpoints.py (4)
src/models/responses.py (1)
ReferencedDocument(164-176)src/models/requests.py (1)
QueryRequest(73-225)src/models/config.py (1)
Action(328-374)src/utils/endpoints.py (1)
validate_model_provider_override(164-184)
⏰ 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 (ci)
- GitHub Check: e2e_tests (azure)
🔇 Additional comments (1)
tests/unit/utils/test_endpoints.py (1)
11-11: LGTM!The import is necessary for the runtime type checks added in the test assertions.
Description
LCORE-814: fixed issues found by Pyright
Type of change
Related Tickets & Documents
Summary by CodeRabbit