LCORE-2334: use specific rule codes #1793
Conversation
WalkthroughTwo test modules refactor exception detail assertions across conversation endpoint unit tests. The changes extract ChangesException Detail Assertion Refactoring
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
tests/unit/app/endpoints/test_conversations.pytests/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
Usepytest.mark.asynciomarker for async tests
Files:
tests/unit/app/endpoints/test_conversations_v2.pytests/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 |
There was a problem hiding this comment.
🧩 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:
- 1: https://github.com/microsoft/pyright/blob/main/docs/comments.md
- 2: https://docs.basedpyright.com/v1.18.3/configuration/comments/
- 3: https://stackoverflow.com/questions/57335636/is-it-possible-to-ignore-pyright-checking-for-one-line
🏁 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.pyRepository: 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:
- 1: https://github.com/microsoft/pyright/blob/main/docs/comments.md
- 2: https://docs.basedpyright.com/v1.18.3/configuration/comments/
- 3: https://stackoverflow.com/questions/57335636/is-it-possible-to-ignore-pyright-checking-for-one-line
🏁 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" || trueRepository: 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" || trueRepository: 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.
| request=None # type: ignore[arg-type] | ||
| ) |
There was a problem hiding this comment.
🧩 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.pyRepository: 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.
| 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.
Description
LCORE-2334: use specific rule codes
Type of change
Tools used to create PR
Related Tickets & Documents
Summary by CodeRabbit