Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LCORE-2334: use specific rule codes #1793

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2334-use-specific-rule-codes-
May 26, 2026
Merged

LCORE-2334: use specific rule codes #1793
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2334-use-specific-rule-codes-

Conversation

@tisnik

@tisnik tisnik commented May 26, 2026

Copy link
Copy Markdown
Contributor

Description

LCORE-2334: use specific rule codes

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
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-2334

Summary by CodeRabbit

  • Tests
    • Updated unit test assertions and type-checking directives for conversation endpoint tests to improve code maintainability.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Two test modules refactor exception detail assertions across conversation endpoint unit tests. The changes extract exc_info.value.detail["response"] and ["cause"] values into intermediate local variables, replacing generic # type: ignore comments with specific # pyright: ignore[...] directives. No endpoint logic is modified.

Changes

Exception Detail Assertion Refactoring

Layer / File(s) Summary
Conversation endpoint test assertions
tests/unit/app/endpoints/test_conversations.py
Refactors 30 test assertions across GET retrieve, GET list, DELETE, and UPDATE conversation endpoints. Extracts exception detail values (response, cause) into local variables before assertions, and updates all type-suppression directives to specific Pyright ignore codes (e.g., reportArgumentType, reportOperatorIssue).
Conversation v2 endpoint test assertions
tests/unit/app/endpoints/test_conversations_v2.py
Refactors 6 test assertions in utility and endpoint tests. Extracts detail["response"] into local variables before substring checks and updates type-suppression comments to Pyright-specific ignore codes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • lightspeed-core/lightspeed-stack#1791: Updates unit test assertions to extract HTTPException.detail values into local variables and replace generic type-ignore with specific Pyright ignore rule codes, following the same refactoring pattern.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'specific rule codes' but the changes only refactor test assertions and type-checking directives without implementing rule code changes. Update the title to accurately reflect the actual changes, such as 'Refactor test assertions and update type-checking directives to use Pyright-specific ignores' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/app/endpoints/test_conversations_v2.py`:
- Line 898: Replace the bare suppression on the assertion containing
"Conversation cache not configured" with a rule-specific Pyright suppression:
run Pyright (or re-run the test linter) to get the exact diagnostic code for
that assertion and replace `# pyright: ignore` with `# pyright:
ignore[<diagnostic-name>]` (e.g., `# pyright: ignore[reportSomeDiagnostic]`),
leaving the assertion text `assert "Conversation cache not configured" in
response_text` unchanged so the suppression targets only the specific Pyright
rule reported for that line.

In `@tests/unit/app/endpoints/test_conversations.py`:
- Around line 533-534: The test code still uses a mypy-style inline ignore
"request=None  # type: ignore[arg-type]"; replace that with the Pyright-specific
ignore comment "# pyright: ignore[reportArgumentType]" so it matches the
surrounding file convention—locate the call site where the test passes
request=None (look for the variable named request or the test function invoking
the endpoint in test_conversations.py around the request assignment) and change
the trailing comment accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: db4fe2ea-773d-40ec-864f-72204bf4c5d7

📥 Commits

Reviewing files that changed from the base of the PR and between 083d1ae and 896c56a.

📒 Files selected for processing (2)
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_conversations_v2.py
📜 Review details
⏰ 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). (2)
  • GitHub Check: Pylinter
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🧰 Additional context used
📓 Path-based instructions (1)
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async tests

Files:

  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_conversations.py

detail_dict = cast(dict[str, Any], detail)
response_text = detail_dict.get("response", "")
assert "Conversation cache not configured" in response_text # type: ignore
assert "Conversation cache not configured" in response_text # pyright: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does Pyright support bare # pyright: ignore and what is the recommended syntax for rule-specific suppressions?

💡 Result:

Yes, Pyright supports bare # pyright: ignore comments to suppress all diagnostics on a specific line [1][2]. This syntax is preferred over the generic # type: ignore because it is specific to Pyright, preventing potential collisions with other type checkers [1][3]. The recommended syntax for rule-specific suppression is to include a comma-delimited list of diagnostic rule names within square brackets immediately following the ignore directive [1][2]. Example of rule-specific suppression: # pyright: ignore [reportPrivateUsage, reportGeneralTypeIssues] This approach suppresses only the diagnostics associated with the specified rules, leaving other potential issues on the same line to be reported [1][2]. By using this method, you can keep your code clean while maintaining precise control over your diagnostic suppressions [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show context around the flagged line
sed -n '880,910p' tests/unit/app/endpoints/test_conversations_v2.py | nl -ba

# Find other pyright ignores in this file for consistency/patterns
rg -n --fixed-string "pyright: ignore" tests/unit/app/endpoints/test_conversations_v2.py

# If there are any rule-code ignores, list them too
rg -n --fixed-string "pyright: ignore[" tests/unit/app/endpoints/test_conversations_v2.py

Repository: lightspeed-core/lightspeed-stack

Length of output: 119


🌐 Web query:

pyright "ignore[]" syntax example report... which rule is suppressed by # pyright: ignore on that line?

💡 Result:

The syntax # pyright: ignore is used in Python code to suppress Pyright diagnostic reports on the specific line where the comment appears [1][2]. Regarding which rules are suppressed: 1. Without specified rules: If used as a naked # pyright: ignore comment, it suppresses all Pyright diagnostics generated for that specific line [1][2]. 2. With specified rules: If you include an optional, comma-delimited list of diagnostic rule names within square brackets, only the specified rules are suppressed [1][2]. For example: # pyright: ignore [reportPrivateUsage, reportGeneralTypeIssues] This suppresses only reportPrivateUsage and reportGeneralTypeIssues while allowing other diagnostics on that same line to be reported [1][2]. This mechanism is preferred over the standard # type: ignore comment in environments where you use multiple type checkers (such as Mypy and Pyright) and wish to restrict the suppression specifically to Pyright, avoiding interference with other tools [1][3][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="tests/unit/app/endpoints/test_conversations_v2.py"
START=890
END=905

# Print requested range with line numbers (no nl dependency)
awk -v s="$START" -v e="$END" 'NR>=s && NR<=e {printf "%d:%s\n", NR, $0}' "$FILE"

# Find all pyright ignores in this file
rg -n --fixed-string "pyright: ignore" "$FILE"

# Find rule-specific ignores (pyright: ignore[...]) in this file
rg -n --fixed-string "pyright: ignore[" "$FILE" || true

Repository: lightspeed-core/lightspeed-stack

Length of output: 1270


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="tests/unit/app/endpoints/test_conversations_v2.py"

# Re-display around the flagged line with line numbers
awk 'NR>=890 && NR<=905 {printf "%d:%s\n", NR, $0}' "$FILE"

# Find all pyright ignore comments in this file
rg -n --fixed-strings "pyright: ignore" "$FILE"

# Find rule-specific ignores, if any, in this file
rg -n --fixed-strings "pyright: ignore[" "$FILE" || true

Repository: lightspeed-core/lightspeed-stack

Length of output: 1705


Replace bare # pyright: ignore with rule-specific suppression on this line.

tests/unit/app/endpoints/test_conversations_v2.py:898 uses a bare # pyright: ignore, while nearby lines already use rule-specific ignores like # pyright: ignore[reportArgumentType]. Update this suppression to # pyright: ignore[<rule-code>] using the specific Pyright diagnostic name for that statement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/app/endpoints/test_conversations_v2.py` at line 898, Replace the
bare suppression on the assertion containing "Conversation cache not configured"
with a rule-specific Pyright suppression: run Pyright (or re-run the test
linter) to get the exact diagnostic code for that assertion and replace `#
pyright: ignore` with `# pyright: ignore[<diagnostic-name>]` (e.g., `# pyright:
ignore[reportSomeDiagnostic]`), leaving the assertion text `assert "Conversation
cache not configured" in response_text` unchanged so the suppression targets
only the specific Pyright rule reported for that line.

Comment on lines +533 to 534
request=None # type: ignore[arg-type]
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify mixed ignore styles in the touched test files
rg -n --type=py 'type:\s*ignore|pyright:\s*ignore' tests/unit/app/endpoints/test_conversations.py tests/unit/app/endpoints/test_conversations_v2.py

Repository: lightspeed-core/lightspeed-stack

Length of output: 5233


Replace remaining type: ignore[arg-type] with Pyright ignore rule code
tests/unit/app/endpoints/test_conversations.py still uses request=None # type: ignore[arg-type] at lines 533-534, while the surrounding file uses # pyright: ignore[...]; switch to # pyright: ignore[reportArgumentType] for consistency.

Suggested fix
-            request=None  # type: ignore[arg-type]
+            request=None  # pyright: ignore[reportArgumentType]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
request=None # type: ignore[arg-type]
)
request=None # pyright: ignore[reportArgumentType]
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/app/endpoints/test_conversations.py` around lines 533 - 534, The
test code still uses a mypy-style inline ignore "request=None  # type:
ignore[arg-type]"; replace that with the Pyright-specific ignore comment "#
pyright: ignore[reportArgumentType]" so it matches the surrounding file
convention—locate the call site where the test passes request=None (look for the
variable named request or the test function invoking the endpoint in
test_conversations.py around the request assignment) and change the trailing
comment accordingly.

@tisnik tisnik merged commit ef23c78 into lightspeed-core:main May 26, 2026
31 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