Skip to content

LCORE-740: type hints in endpoint utils#731

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-740-type-hints-in-endpoint-utils
Oct 30, 2025
Merged

LCORE-740: type hints in endpoint utils#731
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-740-type-hints-in-endpoint-utils

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Oct 30, 2025

Description

LCORE-740: type hints in endpoint utils

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-740

Summary by CodeRabbit

  • Tests
    • Added type annotations to test configuration and fixtures for improved code clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Walkthrough

These changes add comprehensive type annotations to test files. The first file adds a type annotation to a global config_dict variable. The second file introduces pathlib.Path import and adds explicit type hints to all fixtures and test functions, specifying parameter and return types across the test suite.

Changes

Cohort / File(s) Summary
Global configuration type annotation
tests/unit/__init__.py
Added Any import from typing and annotated global variable config_dict with type dict[str, Any]
Test fixture and function type annotations
tests/unit/utils/test_endpoints.py
Added Path import from pathlib; added explicit type hints to all fixture functions (returning AppConfig, QueryRequest, str) and test functions (parameters and -> None return types); expanded signatures for parametrized tests with explicit type annotations for AppConfig, QueryRequest, AgentFixtures, and MockerFixture types

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Changes are purely type annotations with no behavioral modifications
  • Additions are homogeneous and repetitive across the test file
  • No logic changes, control flow updates, or complex reasoning required

Poem

🐰 With types now dancing in rows so neat,
Each fixture and test is complete!
From Any to AppConfig's grace,
Type hints put decorations in place. ✨

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 PR title "LCORE-740: type hints in endpoint utils" directly describes the main change in the pull request. The changeset focuses on adding comprehensive type annotations (parameter types, return types, and variable type hints) across test files, with the primary focus on tests/unit/utils/test_endpoints.py. The title is concise, clear, and specific—it accurately conveys that type hints were added to endpoint utilities without using vague terminology or unnecessary noise. A teammate reviewing the commit history would immediately understand the purpose of this change.
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 232d515 and 85d3def.

📒 Files selected for processing (2)
  • tests/unit/__init__.py (1 hunks)
  • tests/unit/utils/test_endpoints.py (39 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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/__init__.py
  • tests/unit/utils/test_endpoints.py
**/__init__.py

📄 CodeRabbit inference engine (CLAUDE.md)

Package init.py files contain brief package descriptions

Files:

  • tests/unit/__init__.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/__init__.py
  • 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/__init__.py
  • tests/unit/utils/test_endpoints.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to src/{models/**/*.py,configuration.py} : Use precise type hints in configuration (e.g., Optional[FilePath], PositiveInt, SecretStr)
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to **/*.py : Provide complete type annotations for all function parameters and return types
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to **/*.py : Provide complete type annotations for all class attributes
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to **/*.py : Define type aliases at module level for clarity
📚 Learning: 2025-09-18T16:46:33.353Z
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to src/{models/**/*.py,configuration.py} : Use precise type hints in configuration (e.g., Optional[FilePath], PositiveInt, SecretStr)

Applied to files:

  • tests/unit/__init__.py
📚 Learning: 2025-09-18T16:46:33.353Z
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to tests/**/*.py : Use pytest-mock to create AsyncMock objects for async interactions in tests

Applied to files:

  • tests/unit/utils/test_endpoints.py
🧬 Code graph analysis (1)
tests/unit/utils/test_endpoints.py (4)
tests/unit/utils/test_checks.py (1)
  • input_file_fixture (16-21)
src/configuration.py (1)
  • AppConfig (39-181)
src/models/requests.py (1)
  • QueryRequest (73-225)
src/utils/endpoints.py (2)
  • validate_model_provider_override (207-227)
  • create_referenced_documents (525-559)
⏰ 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 (6)
tests/unit/__init__.py (1)

3-6: LGTM! Type annotation correctly added to module-level configuration.

The addition of Any import and type annotation dict[str, Any] for config_dict follows modern Python syntax and coding guidelines. This properly documents the structure of the configuration dictionary used across unit tests.

tests/unit/utils/test_endpoints.py (5)

5-5: LGTM! Import additions support comprehensive type annotations.

The imports of Path from pathlib and AgentFixtures from conftest are correctly added to support type annotations throughout the test file.

Also applies to: 22-22


28-164: LGTM! Comprehensive and accurate type annotations for all fixtures.

All fixture functions now have complete type annotations with accurate parameter types (Path) and return types (str, AppConfig, QueryRequest). The annotations follow modern Python syntax and align with coding guidelines.


167-260: LGTM! Complete type annotations for system prompt test functions.

All test functions now have explicit parameter types matching their fixture dependencies and appropriate -> None return types. The annotations are consistent and follow coding guidelines.


263-803: LGTM! Complete type annotations for async agent test functions.

All async test functions have accurate type annotations for their parameters (AgentFixtures, MockerFixture, AppConfig) and appropriate -> None return types. The annotations correctly leverage the imported fixture types.


805-1038: LGTM! Complete type annotations for remaining test functions and test class methods.

All remaining test functions and test class methods have accurate type annotations with appropriate parameter types and -> None return types. The comprehensive type annotation coverage across the entire file enhances code clarity and follows coding guidelines.


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 c5f07e9 into lightspeed-core:main Oct 30, 2025
18 of 20 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