refactor: Organize Excel helper classes into modular structure#62
Conversation
Move Excel helper classes to dedicated subdirectory for better organization: - ExcelRangeCalculator -> src/excel/range_calculator.py - ExcelMergedCellHandler -> src/excel/merged_cell_handler.py - ExcelPaneManager -> src/excel/pane_manager.py - ExcelStyleExtractor -> src/excel/style_extractor.py Add src/excel/__init__.py to export all helper classes. Update all imports in src/ and tests/ to use new module structure. Benefits: - Clearer separation of Excel-related utilities - Better project structure (src/excel/ for Excel helpers) - Maintains all existing functionality (142 tests pass) - Improved code organization without functional changes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Move Excel-related test files to dedicated subdirectory: - test_excel_range_calculator.py -> tests/excel/ - test_excel_merged_cell_handler.py -> tests/excel/ - test_excel_pane_manager.py -> tests/excel/ - test_excel_style_extractor.py -> tests/excel/ Benefits: - Test structure mirrors source code structure (src/excel/ <-> tests/excel/) - Better organization and discoverability - All 142 tests continue to pass (76 unit + 66 integration) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary of ChangesHello @k-ibaraki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! このプルリクエストは、SharePoint Excelパーサーの内部実装をモジュール化することで、コードベースの保守性とテスト容易性を大幅に向上させることを目的としています。主要なExcel処理ロジックを独立したヘルパークラスに分離し、それぞれの責務を明確にしました。これにより、コードの可読性が向上し、将来的な機能追加や変更が容易になります。既存の公開APIには影響がなく、全てのテストがパスしているため、機能的な変更はありません。 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
SharePoint Excel パーサーの内部実装をヘルパークラスへ分割し、フォルダ構成も含めて整理したことで、責務分離とテスト容易性を大きく改善するPRです。
Changes:
SharePointExcelParser内の範囲計算・マージセル・freeze_panes・スタイル抽出をsrc/excel/配下のモジュールへ分離- 既存統合テストの一部をヘルパークラス参照に更新し、新規ユニットテスト(
tests/excel/)を追加 - パッケージバージョン更新に伴い
uv.lockを更新
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | パッケージバージョン更新(0.4.0 → 0.5.0)を反映 |
| src/sharepoint_excel.py | Excel処理の一部ロジックをヘルパーへ委譲し、責務を軽量化 |
| src/excel/init.py | 抽出したヘルパークラスの公開エントリポイントを追加 |
| src/excel/range_calculator.py | セル範囲の計算・正規化・検証を集約 |
| src/excel/merged_cell_handler.py | マージセル情報の部分展開・アンカー値決定を集約 |
| src/excel/pane_manager.py | freeze_panes の取得・整形・上限検証を集約 |
| src/excel/style_extractor.py | スタイル(色・サイズ)抽出を集約 |
| tests/test_sharepoint_excel.py | 既存統合テストの一部を新ヘルパー利用に更新 |
| tests/excel/test_excel_range_calculator.py | ExcelRangeCalculator のユニットテスト追加 |
| tests/excel/test_excel_merged_cell_handler.py | ExcelMergedCellHandler のユニットテスト追加 |
| tests/excel/test_excel_pane_manager.py | ExcelPaneManager のユニットテスト追加 |
| tests/excel/test_excel_style_extractor.py | ExcelStyleExtractor のユニットテスト追加 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Apply all suggested improvements from code review: 1. Remove duplicate dict initialization in merged_cell_handler.py - Remove redundant None initialization (lines 39-40) - Add type hints at actual initialization (lines 73-74) 2. Narrow exception handling in range_calculator.py - Change `except Exception:` to `except ValueError:` for better specificity 3. Restore backward compatibility in calculate_range_size - Add try-except block to return (0, 0) on error - Maintain original behavior for invalid ranges - Add logging for debugging 4. Add defensive check for negative frozen_rows - Prevent negative values in pane_manager.py - Return (True, 0) for negative input 5. Restore duplicate normalization check in tests - Add mock-based call count verification - Ensure ExcelRangeCalculator methods called only once - Verify no performance regression from refactoring All 220 tests pass. Quality checks pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Self-review findings and fixes: 1. Fix validate_frozen_rows docstring accuracy - Corrected is_valid description: only False when exceeds limit - Clarified validated_frozen_rows behavior for negative values - Implementation and documentation now match 2. Improve expand_axis_range documentation - Add concrete examples first for better understanding - Add Args and Returns sections - Replace abstract description with clear examples Quality metrics maintained: - All 220 tests pass - Coverage: 81-100% (helper classes) - Type check, lint, format: all pass Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
概要
SharePoint Excel パーサーの保守性向上のため、内部実装をモジュール化してフォルダ構造を整理しました。
変更内容
ファイル構造の整理
新規ディレクトリ:
src/excel/- Excel処理ヘルパークラスtests/excel/- Excel関連の単体テスト抽出されたヘルパークラス:
ExcelRangeCalculator(range_calculator.py) - セル範囲の計算・変換・検証ExcelMergedCellHandler(merged_cell_handler.py) - マージセル情報の構築と管理ExcelPaneManager(pane_manager.py) - 固定行列(freeze_panes)の処理ExcelStyleExtractor(style_extractor.py) - セルスタイル情報の抽出コード改善
sharepoint_excel.pyが 1,114行 → 680行(39%削減)機能不変の保証
✅ 公開APIは完全に互換性維持
sharepoint_excelMCPツールのパラメータ・戻り値は一切変更なし✅ 全テスト合格
✅ 品質チェック合格
実装方針
構造改善の効果
Before
After
関連Issue
このリファクタリングは、以前から計画されていたコードベースの保守性向上施策の一環です。
レビューポイント
🤖 Generated with Claude Code