Skip to content

Commit 330d426

Browse files
web-flowclaude
andcommitted
fix: ruff/mypyエラー修正 (E402, F401, F841, E741, E731, 型エラー)
- E402: インポート順序修正(ロガー初期化をインポート完了後に移動) - F401: 未使用インポート削除(Dict in json_repository/__init__.py) - F841: 未使用変数修正(テストファイル) - E741: 曖昧な変数名修正(l → level_name) - E731: lambda式をdef関数に変更 - mypy型エラー: castを使用して型アサーション追加 - StructuredLoggerにinfoメソッド追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bf612d2 commit 330d426

46 files changed

Lines changed: 113 additions & 85 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

EpisodicRAG/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9898

9999
---
100100

101+
<details>
102+
<summary>Archive (v2.x and earlier)</summary>
103+
101104
## [2.3.0] - 2025-11-28
102105

103106
### Breaking Changes
@@ -434,6 +437,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
434437
- Provisional/Regular Digest生成
435438
- まだらボケ検出機能
436439

440+
</details>
441+
437442
---
438443

439444
## バージョニング規則

EpisodicRAG/scripts/application/finalize/persistence.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
"""
88

99
from pathlib import Path
10-
from typing import Callable, List, Optional
10+
from typing import Callable, List, Optional, cast
1111

1212
from application.grand import GrandDigestManager, ShadowGrandDigestManager
1313
from application.tracking import DigestTimesTracker
1414
from config import DigestConfig
15-
from domain.validators import is_valid_dict
1615
from domain.constants import (
1716
LEVEL_CONFIG,
1817
LOG_PREFIX_DECISION,
@@ -22,8 +21,15 @@
2221
from domain.error_formatter import get_error_formatter
2322
from domain.exceptions import DigestError, FileIOError, ValidationError
2423
from domain.level_registry import get_level_registry
25-
from domain.types import RegularDigestData, as_dict
26-
from infrastructure import get_default_confirm_callback, get_structured_logger, log_debug, log_warning, save_json
24+
from domain.types import OverallDigestData, RegularDigestData, as_dict
25+
from domain.validators import is_valid_dict
26+
from infrastructure import (
27+
get_default_confirm_callback,
28+
get_structured_logger,
29+
log_debug,
30+
log_warning,
31+
save_json,
32+
)
2733

2834
_logger = get_structured_logger(__name__)
2935

@@ -124,7 +130,7 @@ def update_grand_digest(
124130
formatter = get_error_formatter()
125131
raise DigestError(formatter.validation.validation_error("RegularDigest", "has no valid overall_digest", None))
126132
# GrandDigestManager.update_digestは例外を投げる(失敗時)
127-
self.grand_digest_manager.update_digest(level, new_digest_name, overall_digest)
133+
self.grand_digest_manager.update_digest(level, new_digest_name, cast(OverallDigestData, overall_digest))
128134

129135
def _update_shadow_cascade(self, level: str) -> None:
130136
"""

EpisodicRAG/scripts/application/finalize/provisional_loader.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from application.grand import ShadowGrandDigestManager
1313
from config import DigestConfig
14-
from domain.validators import is_valid_dict
1514
from domain.constants import (
1615
LEVEL_CONFIG,
1716
LOG_PREFIX_DECISION,
@@ -22,7 +21,14 @@
2221
from domain.error_formatter import get_error_formatter
2322
from domain.exceptions import DigestError
2423
from domain.types import IndividualDigestData, OverallDigestData
25-
from infrastructure import get_structured_logger, load_json, log_debug, log_warning, try_read_json_from_file
24+
from domain.validators import is_valid_dict
25+
from infrastructure import (
26+
get_structured_logger,
27+
load_json,
28+
log_debug,
29+
log_warning,
30+
try_read_json_from_file,
31+
)
2632

2733
_logger = get_structured_logger(__name__)
2834

EpisodicRAG/scripts/application/finalize/shadow_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from typing import Any, Callable, List, Optional, Tuple
1010

1111
from application.grand import ShadowGrandDigestManager
12-
from domain.validators import is_valid_dict, is_valid_list
1312
from domain.error_formatter import get_error_formatter
1413
from domain.exceptions import DigestError, ValidationError
1514
from domain.file_naming import extract_file_number
1615
from domain.types import OverallDigestData
16+
from domain.validators import is_valid_dict, is_valid_list
1717
from infrastructure import get_default_confirm_callback, get_structured_logger, log_warning
1818

1919
_logger = get_structured_logger(__name__)

EpisodicRAG/scripts/application/grand/grand_digest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
"""
3838

3939
from datetime import datetime
40+
from typing import cast
4041

4142
from config import DigestConfig
42-
from domain.validators import is_valid_dict
4343
from domain.constants import (
4444
LEVEL_NAMES,
4545
LOG_PREFIX_STATE,
@@ -48,6 +48,7 @@
4848
from domain.error_formatter import get_error_formatter
4949
from domain.exceptions import DigestError
5050
from domain.types import GrandDigestData, OverallDigestData, as_dict
51+
from domain.validators import is_valid_dict
5152
from domain.version import DIGEST_FORMAT_VERSION
5253
from infrastructure import get_structured_logger, load_json_with_template, log_debug, save_json
5354

@@ -169,5 +170,5 @@ def update_digest(
169170
log_debug(f"{LOG_PREFIX_STATE} updated_timestamp: {grand_data['metadata']['last_updated']}")
170171

171172
# 保存
172-
self.save(grand_data)
173+
self.save(cast(GrandDigestData, grand_data))
173174
_logger.info(f"Updated GrandDigest.txt for level: {level}")

EpisodicRAG/scripts/application/shadow/cascade_processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@
4949
from domain.validators import is_valid_overall_digest
5050
from infrastructure import get_structured_logger
5151

52-
# 構造化ロガー
53-
_logger = get_structured_logger(__name__)
54-
5552
from .file_detector import FileDetector
5653
from .shadow_io import ShadowIO
5754
from .template import ShadowTemplate
5855

5956
if TYPE_CHECKING:
6057
from .file_appender import FileAppender
6158

59+
# 構造化ロガー
60+
_logger = get_structured_logger(__name__)
61+
6262

6363
class CascadeProcessor:
6464
"""

EpisodicRAG/scripts/application/shadow/file_appender.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
try_read_json_from_file,
1919
)
2020

21-
# 構造化ロガー
22-
_logger = get_structured_logger(__name__)
23-
2421
from .file_detector import FileDetector
2522
from .placeholder_manager import PlaceholderManager
2623
from .shadow_io import ShadowIO
2724
from .template import ShadowTemplate
2825

26+
# 構造化ロガー
27+
_logger = get_structured_logger(__name__)
28+
2929

3030
class FileAppender:
3131
"""ファイル追加処理クラス"""

EpisodicRAG/scripts/application/shadow/shadow_updater.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from domain.types import LevelHierarchyEntry, OverallDigestData
1313
from infrastructure import get_structured_logger
1414

15-
_logger = get_structured_logger(__name__)
16-
1715
from .cascade_processor import CascadeProcessor
1816
from .file_appender import FileAppender
1917
from .file_detector import FileDetector
2018
from .placeholder_manager import PlaceholderManager
2119
from .shadow_io import ShadowIO
2220
from .template import ShadowTemplate
2321

22+
_logger = get_structured_logger(__name__)
23+
2424

2525
class ShadowUpdater:
2626
"""

EpisodicRAG/scripts/application/tracking/digest_times.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from typing import List, Optional, Union, cast
1212

1313
from config import DigestConfig
14-
from domain.validators import is_valid_list
1514
from domain.constants import LEVEL_NAMES
1615
from domain.file_naming import extract_number_only, extract_numbers_formatted
1716
from domain.types import DigestTimesData
17+
from domain.validators import is_valid_list
1818
from infrastructure import get_structured_logger, load_json_with_template, log_warning, save_json
1919

2020
_logger = get_structured_logger(__name__)

EpisodicRAG/scripts/config/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@
5252
from pathlib import Path
5353
from typing import List, Literal, Optional
5454

55-
# Config層専用の型・例外・エラーメッセージ
56-
from .exceptions import ConfigError
57-
from .types import ConfigData
58-
from .error_messages import initialization_failed_message
59-
6055
# 内部コンポーネント
6156
from .config_loader import ConfigLoader
6257

6358
# 後方互換性のため DirectoryValidator も公開(ConfigValidatorへのエイリアス)
6459
from .config_validator import ConfigValidator
6560
from .config_validator import DirectoryValidator as DirectoryValidator # noqa: PLC0414
61+
from .error_messages import initialization_failed_message
62+
63+
# Config層専用の型・例外・エラーメッセージ
64+
from .exceptions import ConfigError
6665
from .level_path_service import LevelPathService
6766
from .path_resolver import PathResolver
6867
from .plugin_root_resolver import find_plugin_root
6968
from .source_path_resolver import SourcePathResolver
7069
from .threshold_provider import ThresholdProvider
70+
from .types import ConfigData
7171

7272
# Config層専用logger(Infrastructure層に依存しない)
7373
_logger = logging.getLogger("episodic_rag.config")

0 commit comments

Comments
 (0)