Skip to content

Commit afce94d

Browse files
k-ibarakiclaude
andcommitted
fix: Address additional AI review feedback
Code improvements: - Add type annotation to _normalize_range_data method - Add empty data handling to prevent IndexError Documentation improvements: - Clarify metadata_only purpose: reduce response size (not processing load) - Update parameter table descriptions for clarity - Emphasize response size reduction in use cases Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1c4f501 commit afce94d

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ The `sharepoint_excel` tool allows you to read and search Excel files in SharePo
188188
| `cell_range` | str \| None | None | Cell range (e.g., "A1:D10") |
189189
| `include_formatting` | bool | False | Include formatting information |
190190
| `include_header` | bool | True | Auto-detect and separate header rows using `freeze_panes` |
191-
| `metadata_only` | bool | False | Return only file and worksheet metadata without cell contents |
191+
| `metadata_only` | bool | False | Exclude data rows to return only metadata (reduce response size) |
192192

193193
### Basic Workflow
194194

@@ -346,7 +346,7 @@ result = sharepoint_excel(
346346
- Inspect large file structure before fetching data
347347
- Understand what headers exist in each sheet
348348
- Determine the necessary `cell_range` before retrieving full data
349-
- Reduce token usage
349+
- Significantly reduce response size (save tokens)
350350

351351
**Recommended Workflow:**
352352
1. Use `metadata_only=True` to inspect file structure

docs/usage_ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SHAREPOINT_SITE_NAME=@onedrive,sales-team,customer-portal
188188
| `cell_range` | str \| None | None | セル範囲(例: "A1:D10") |
189189
| `include_formatting` | bool | False | 書式情報を含めるか |
190190
| `include_header` | bool | True | ヘッダー行を自動検出して分離するか(`freeze_panes`を使用) |
191-
| `metadata_only` | bool | False | メタデータ(シート名やセル範囲など)のみを返し、セル内容は取得しないかどうか |
191+
| `metadata_only` | bool | False | データ行を除外してメタデータのみ返す(応答サイズを削減) |
192192

193193
### 基本的なワークフロー
194194

@@ -346,7 +346,7 @@ result = sharepoint_excel(
346346
- 大きなファイルの構造を事前に確認
347347
- どのシートにどんなヘッダーがあるかを把握
348348
- 必要な`cell_range`を決定してから本データを取得
349-
- トークン使用量の削減
349+
- 応答サイズを大幅に削減(トークン使用量の節約)
350350

351351
**推奨ワークフロー:**
352352
1. `metadata_only=True`でファイル構造を確認

src/sharepoint_excel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def _split_rows_by_header(
478478

479479
return (header_rows, data_rows)
480480

481-
def _normalize_range_data(self, range_data):
481+
def _normalize_range_data(self, range_data: Any) -> tuple[tuple[Cell, ...], ...]:
482482
"""
483483
openpyxlの範囲データを統一的なタプルのタプル形式に変換
484484
@@ -491,7 +491,10 @@ def _normalize_range_data(self, range_data):
491491
if isinstance(range_data, Cell):
492492
# 単一セルの場合
493493
return ((range_data,),)
494-
elif range_data and not isinstance(range_data[0], tuple):
494+
elif not range_data:
495+
# 空の場合
496+
return ()
497+
elif not isinstance(range_data[0], tuple):
495498
# 単一列/行の場合
496499
return (range_data,)
497500
else:

0 commit comments

Comments
 (0)