Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Oct 14, 2025

Description

LCORE-739: added return type to unit tests

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

Summary by CodeRabbit

  • Tests
    • Added explicit None return type annotations across multiple unit and async tests to align with stricter typing and improve readability and static analysis.
    • Standardized test function signatures for consistency and maintainability.
    • No changes to logic, control flow, or behavior; test outcomes remain the same.
    • No new dependencies introduced; this is a non-functional, code-quality update.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Explicit return type annotations (-> None) were added to test functions in tests/unit/metrics/test_utis.py and tests/unit/utils/test_common.py. No logic, control flow, or dependencies were changed.

Changes

Cohort / File(s) Summary
Metrics tests: add explicit return types
tests/unit/metrics/test_utis.py
Annotated two test functions with -> None; no logic changes.
Utils tests (async): add explicit return types
tests/unit/utils/test_common.py
Annotated multiple async test functions with -> None; no behavioral changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

A nibble of types on a testing trail,
I twitch my nose at each None-filled sail.
No logic hops, just signatures neat—
Carrots aligned, a typing treat.
Thump-thump! The suite is clean and bright,
A rabbit approves this mypy delight. 🥕🐇

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 pull request title succinctly describes the main change—adding return type annotations to unit tests—and includes the related ticket ID for traceability without extraneous detail. It is clear, concise, and directly reflects the change made to the code.
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

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: 0

🧹 Nitpick comments (2)
tests/unit/metrics/test_utis.py (1)

6-6: LGTM! Return type annotations improve type safety.

The explicit -> None return type annotations align with the coding guidelines requirement for complete type annotations.

For complete type coverage, consider adding type hints to the mocker parameter:

+from pytest_mock import MockerFixture
+
-async def test_setup_model_metrics(mocker) -> None:
+async def test_setup_model_metrics(mocker: MockerFixture) -> None:

-def test_update_llm_token_count_from_turn(mocker) -> None:
+def test_update_llm_token_count_from_turn(mocker: MockerFixture) -> None:

As per coding guidelines

Also applies to: 79-79

tests/unit/utils/test_common.py (1)

21-21: LGTM! Return type annotations improve type safety.

The explicit -> None return type annotations on all async test functions align with the coding guidelines requirement for complete type annotations.

For complete type coverage, consider adding type hints to the mocker parameter across all test functions:

+from pytest_mock import MockerFixture
+
-async def test_register_mcp_servers_empty_list(mocker) -> None:
+async def test_register_mcp_servers_empty_list(mocker: MockerFixture) -> None:

-async def test_register_mcp_servers_single_server_not_registered(mocker) -> None:
+async def test_register_mcp_servers_single_server_not_registered(mocker: MockerFixture) -> None:

-async def test_register_mcp_servers_single_server_already_registered(mocker) -> None:
+async def test_register_mcp_servers_single_server_already_registered(mocker: MockerFixture) -> None:

-async def test_register_mcp_servers_multiple_servers_mixed_registration(mocker) -> None:
+async def test_register_mcp_servers_multiple_servers_mixed_registration(mocker: MockerFixture) -> None:

-async def test_register_mcp_servers_with_custom_provider(mocker) -> None:
+async def test_register_mcp_servers_with_custom_provider(mocker: MockerFixture) -> None:

-async def test_register_mcp_servers_async_with_library_client(mocker) -> None:
+async def test_register_mcp_servers_async_with_library_client(mocker: MockerFixture) -> None:

As per coding guidelines

Also applies to: 52-52, 97-97, 135-135, 197-197, 238-238

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 491b29b and 0ac867a.

📒 Files selected for processing (2)
  • tests/unit/metrics/test_utis.py (2 hunks)
  • tests/unit/utils/test_common.py (6 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/metrics/test_utis.py
  • tests/unit/utils/test_common.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/metrics/test_utis.py
  • tests/unit/utils/test_common.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/metrics/test_utis.py
  • tests/unit/utils/test_common.py
⏰ 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)

@tisnik tisnik merged commit 3530fdc into lightspeed-core:main Oct 14, 2025
18 of 20 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 19, 2025
15 tasks
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