Skip to content

Commit f630ded

Browse files
k-ibarakiclaude
andcommitted
fix: address AI review comments
- Clarify "Header detection" wording in tool description to specify frozen_rows=0 condition - Fix test_include_frozen_rows_single_cell docstring to match actual behavior (header + specified cell) - Add condition to skip header_detection warning when expand_axis_range=True - Add test case for expand_axis_range=True (no warning expected) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 37574a0 commit f630ded

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

src/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ def register_tools():
552552
"Response includes cell data in 'rows' (value and coordinate) and structural information "
553553
"(sheet name, dimensions, frozen_rows, frozen_cols, freeze_panes when present, merged_ranges when merged cells exist). "
554554
"Cell styles (include_cell_styles, default: false): background colors and sizes. Use only for color-coded data extraction. "
555-
"Header detection: Cannot be auto-detected from frozen_rows. "
555+
"Header detection: For sheets with frozen_rows > 0, headers are automatically included with include_frozen_rows=True (default). "
556+
"For sheets with frozen_rows=0, headers are not automatically included and context may be unclear. "
556557
"ALWAYS read exactly 5 rows for header check: 'A1:Z5' (NOT 'A1:Z50' or more). "
557558
"Prefer 'query' search when possible to locate data first. "
558559
"Workflow: 1) Search OR read 'A1:Z5' for header check, "

src/sharepoint_excel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,9 @@ def _parse_sheet(
453453
sheet_data["frozen_rows"] = frozen_rows
454454
sheet_data["frozen_cols"] = frozen_cols
455455

456-
# frozen_rows=0 かつ cell_range指定時の警告
457-
if frozen_rows == 0 and cell_range:
456+
# frozen_rows=0 かつ cell_range指定時、expand_axis_range=Falseの場合のみ警告
457+
# expand_axis_range=Trueの場合は1行目/A列が含まれるため警告不要
458+
if frozen_rows == 0 and cell_range and not expand_axis_range:
458459
sheet_data["header_detection"] = {
459460
"status": "no_frozen_rows",
460461
"frozen_rows": 0,

tests/test_sharepoint_excel.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def test_include_frozen_rows_range_includes_headers(self):
12001200
assert a2_count == 1
12011201

12021202
def test_include_frozen_rows_single_cell(self):
1203-
"""単一セル指定時にデフォルト(expand_axis_range=False)ではヘッダーのみ追加"""
1203+
"""単一セル指定時にデフォルト(expand_axis_range=False)では軸拡張せずヘッダー + 指定セルが追加される"""
12041204
# frozen_rows=2のExcelファイルを作成
12051205
excel_bytes = self._create_frozen_rows_excel("A3")
12061206
self.mock_download_client.download_file.return_value = excel_bytes
@@ -1406,6 +1406,38 @@ def test_header_detection_not_added_when_frozen_rows_exist(self):
14061406
# header_detection は付与されない(frozen_rows > 0)
14071407
assert "header_detection" not in sheet_data
14081408

1409+
def test_header_detection_not_added_when_expand_axis_range_true(self):
1410+
"""expand_axis_range=True の場合は header_detection が付与されない"""
1411+
wb = Workbook()
1412+
ws = wb.active
1413+
ws.title = "TestSheet"
1414+
ws["A1"] = "Header1"
1415+
ws["B1"] = "Header2"
1416+
ws["A5"] = "Data1"
1417+
ws["B5"] = "Data2"
1418+
1419+
excel_bytes = BytesIO()
1420+
wb.save(excel_bytes)
1421+
excel_bytes.seek(0)
1422+
1423+
self.mock_download_client.download_file.return_value = excel_bytes.getvalue()
1424+
1425+
parser = SharePointExcelParser(self.mock_download_client)
1426+
1427+
# frozen_rows=0 だが expand_axis_range=True なので警告不要
1428+
result_json = parser.parse_to_json(
1429+
"test.xlsx", sheet_name="TestSheet", cell_range="A5:B5", expand_axis_range=True
1430+
)
1431+
1432+
result = json.loads(result_json)
1433+
sheet_data = result["sheets"][0]
1434+
1435+
# frozen_rows=0
1436+
assert sheet_data["frozen_rows"] == 0
1437+
1438+
# header_detection は付与されない(expand_axis_range=True で1行目が含まれる)
1439+
assert "header_detection" not in sheet_data
1440+
14091441
def test_include_frozen_rows_with_merged_cells(self):
14101442
"""マージセルとの統合が正しく機能すること"""
14111443
# frozen_rows=2、マージセル付きのExcelファイルを作成

0 commit comments

Comments
 (0)