Skip to content

Commit b75847f

Browse files
committed
fix(pr-157): satisfy code-quality on re-exports and LSP returns
1 parent 99647ea commit b75847f

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

src/pythinker_code/tools/lsp/formatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,4 @@ def format_result(
449449
return formatted, len(calls), file_count
450450
case _:
451451
return str(result), 0, 0
452+
raise AssertionError(f"Unhandled LSP format operation: {operation!r}")

src/pythinker_code/tools/lsp/tool.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from urllib.parse import unquote
1111

1212
import pythinker_host
13-
from pythinker_core.tooling import CallableTool2, ToolReturnValue
13+
from pythinker_core import tooling as _tooling
1414
from pythinker_host.path import HostPath
1515

1616
from pythinker_code.lsp.recommend import get_matching_lsp_plugins
@@ -28,7 +28,7 @@
2828
_GIT_CHECK_IGNORE_TIMEOUT = 5.0
2929

3030

31-
class Lsp(CallableTool2[Params]):
31+
class Lsp(_tooling.CallableTool2[Params]):
3232
name: str = "LSP"
3333
supports_parallel: bool = True
3434
description: str = load_desc(Path(__file__).parent / "tool.md", {})
@@ -44,7 +44,7 @@ def __init__(self, runtime: Runtime) -> None:
4444
self._recommended_exts: set[str] = set()
4545

4646
@override
47-
async def __call__(self, params: Params) -> ToolReturnValue:
47+
async def __call__(self, params: Params) -> _tooling.ToolReturnValue:
4848
builder = ToolResultBuilder(max_chars=MAX_RESULT_SIZE_CHARS, max_line_length=None)
4949

5050
if self._lsp.status() == LspInitStatus.PENDING:
@@ -182,7 +182,9 @@ def _brief(self, params: Params) -> str:
182182
return f"{params.operation} {symbol}"
183183
return f"{params.operation} {params.file_path}:{params.line}:{params.character}"
184184

185-
async def _validate_file(self, file_path: str) -> tuple[str | None, ToolReturnValue | None]:
185+
async def _validate_file(
186+
self, file_path: str
187+
) -> tuple[str | None, _tooling.ToolReturnValue | None]:
186188
builder = ToolResultBuilder(max_chars=MAX_RESULT_SIZE_CHARS, max_line_length=None)
187189

188190
if _is_unc_path(file_path):
@@ -224,7 +226,7 @@ async def _ensure_file_open(
224226
manager: Any,
225227
absolute_path: str,
226228
display_path: str,
227-
) -> ToolReturnValue | None:
229+
) -> _tooling.ToolReturnValue | None:
228230
builder = ToolResultBuilder(max_chars=MAX_RESULT_SIZE_CHARS, max_line_length=None)
229231
host_path = HostPath(absolute_path)
230232
try:
@@ -289,6 +291,7 @@ def _method_and_params(params: Params, absolute_path: str) -> tuple[str, dict[st
289291
return "textDocument/prepareCallHierarchy", text_document
290292
case _:
291293
raise ValueError(f"Unsupported LSP operation: {params.operation}")
294+
raise AssertionError(f"Unsupported LSP operation: {params.operation}")
292295

293296

294297
def _to_location(item: dict[str, Any]) -> dict[str, Any]:

src/pythinker_code/ui/shell/components/markdown.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from pythinker_code.ui.shell.markdown import renderer as _md_renderer
2424
from pythinker_code.ui.shell.markdown import streaming as _md_streaming
2525

26-
# Private re-exports consumed by tests and characterization pins.
2726
_BorderedCodeBlock = _md_elements._BorderedCodeBlock
2827
_ReportTableElement = _md_elements._ReportTableElement
2928
_escape_code_span_pipes = _md_normalizers._escape_code_span_pipes
@@ -84,3 +83,30 @@
8483
"simplify_markdown_report_icons",
8584
"unwrap_fenced_markdown_tables",
8685
]
86+
87+
# Keep characterization-pin re-exports reachable; referenced so static analysis
88+
# treats the module-level bindings as intentionally exported, not dead code.
89+
_REEXPORT_REGISTRY: tuple[object, ...] = (
90+
_BorderedCodeBlock,
91+
_ReportTableElement,
92+
_escape_code_span_pipes,
93+
_get_md_parser,
94+
_loosen_tight_ordered_lists,
95+
_markdown_commit_boundary_cached,
96+
_markdown_style_overrides,
97+
_normalize_markdown_tables,
98+
_normalize_space_aligned_report_blocks,
99+
_normalize_table_block,
100+
_parse_aligned_field_line,
101+
_repair_crammed_markdown_tables,
102+
_simplify_markdown_report_icons,
103+
_unwrap_fenced_markdown_tables,
104+
loosen_tight_ordered_lists,
105+
normalize_markdown_tables,
106+
normalize_space_aligned_report_blocks,
107+
normalize_table_block,
108+
parse_aligned_field_line,
109+
repair_crammed_markdown_tables,
110+
simplify_markdown_report_icons,
111+
unwrap_fenced_markdown_tables,
112+
)

0 commit comments

Comments
 (0)