Skip to content

Commit 35ed241

Browse files
web-flowclaude
andcommitted
style(contextpreloader): ruff format を適用する (25 files)
出力は `python -m ruff format .` そのままで、手による編集を含まない (再実行すれば差分ゼロ=この commit の検証法)。 意味不変の担保は適用前後の実測一致: pytest 112 passed/mypy Success (36 source files)/ruff check All checks passed ruff format --check → 39 files already formatted/フック実起動 exit 0 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 899f07e commit 35ed241

25 files changed

Lines changed: 433 additions & 226 deletions

ContextPreloader/hooks/context_preloader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
This thin launcher resolves the plugin location at runtime, supporting
1010
both marketplace installs and local development paths.
1111
"""
12+
1213
import io
1314
import os
1415
import sys
@@ -23,7 +24,11 @@
2324
_CANDIDATE_PATHS = [
2425
# sys.path へ入れるので str を保つ——Path を入れると import 機構が黙って
2526
# 素通りし ModuleNotFoundError になる(実測)。
26-
str(Path("~/.claude/plugins/marketplaces/plugins-weave/ContextPreloader").expanduser()),
27+
str(
28+
Path(
29+
"~/.claude/plugins/marketplaces/plugins-weave/ContextPreloader"
30+
).expanduser()
31+
),
2732
]
2833

2934
# Allow override via environment variable

ContextPreloader/scripts/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
python -m scripts test # Test sources
1010
python -m scripts profiles # List profiles
1111
"""
12+
1213
from scripts.interfaces.cli import main
1314

1415
if __name__ == "__main__":

ContextPreloader/scripts/application/formatter.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Output formatting functions."""
2+
23
from __future__ import annotations
34

45
from scripts.domain.detection import format_file_size, get_file_type_label
@@ -21,11 +22,7 @@ def format_binary_output(label: str, path: str, size: int, ext: str) -> str:
2122

2223

2324
def format_url_text_output(label: str, url: str, content: str) -> str:
24-
return (
25-
f"=== {label} [URL] ===\n"
26-
f"Source: {url}\n"
27-
f"{content}\n"
28-
)
25+
return f"=== {label} [URL] ===\nSource: {url}\n{content}\n"
2926

3027

3128
def format_url_ref_output(label: str, url: str, content_type: str) -> str:
@@ -38,10 +35,7 @@ def format_url_ref_output(label: str, url: str, content_type: str) -> str:
3835

3936

4037
def format_error_output(label: str, error: str) -> str:
41-
return (
42-
f"=== {label} [ERROR] ===\n"
43-
f"{error}\n"
44-
)
38+
return f"=== {label} [ERROR] ===\n{error}\n"
4539

4640

4741
def format_reference_output(
@@ -76,7 +70,9 @@ def format_summary(
7670
if url_count:
7771
parts.append(f"{url_count} URL{'s' if url_count != 1 else ''}")
7872
if binary_count:
79-
parts.append(f"{binary_count} binary reference{'s' if binary_count != 1 else ''}")
73+
parts.append(
74+
f"{binary_count} binary reference{'s' if binary_count != 1 else ''}"
75+
)
8076

8177
loaded = ", ".join(parts) if parts else "nothing"
8278
return (

ContextPreloader/scripts/application/preloader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Preloader: orchestrates source processing."""
2+
23
from __future__ import annotations
34

45
import sys
@@ -35,7 +36,9 @@ def _run_reference(self, all_sources: list[Source]) -> str:
3536
for source in all_sources:
3637
if not source.enabled:
3738
continue
38-
entries.append((source.path, source.label, source.description, source.priority))
39+
entries.append(
40+
(source.path, source.label, source.description, source.priority)
41+
)
3942
output = format_reference_output(entries)
4043
output_bytes = len(output.encode("utf-8"))
4144
if output_bytes > REFERENCE_OUTPUT_WARNING_BYTES:

ContextPreloader/scripts/application/profile_merger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Profile merging logic."""
2+
23
from __future__ import annotations
34

45
from scripts.domain.models import Source

ContextPreloader/scripts/application/source_processor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Single source processing logic."""
2+
23
from __future__ import annotations
34

45
from dataclasses import dataclass
@@ -21,7 +22,7 @@
2122
@dataclass
2223
class ProcessedSource:
2324
output: str
24-
kind: str # "text" | "url" | "binary" | "error"
25+
kind: str # "text" | "url" | "binary" | "error"
2526
text_size: int # bytes of text output (for summary)
2627

2728

@@ -39,7 +40,9 @@ def process_source(
3940
source.path, settings.encoding, settings.max_lines_per_file
4041
)
4142
output = format_text_output(source.label, content)
42-
return ProcessedSource(output=output, kind="text", text_size=len(content.encode("utf-8")))
43+
return ProcessedSource(
44+
output=output, kind="text", text_size=len(content.encode("utf-8"))
45+
)
4346

4447
elif kind == "url":
4548
content, content_type = fetch_url(source.path, settings.url_timeout)
@@ -49,7 +52,9 @@ def process_source(
4952
return ProcessedSource(output=output, kind="error", text_size=0)
5053
elif content:
5154
output = format_url_text_output(source.label, source.path, content)
52-
return ProcessedSource(output=output, kind="url", text_size=len(content.encode("utf-8")))
55+
return ProcessedSource(
56+
output=output, kind="url", text_size=len(content.encode("utf-8"))
57+
)
5358
else:
5459
output = format_url_ref_output(source.label, source.path, content_type)
5560
return ProcessedSource(output=output, kind="binary", text_size=0)

ContextPreloader/scripts/domain/constants.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
"""Domain constants for ContextPreloader (Single Source of Truth)."""
44

55
DEFAULT_TEXT_EXTENSIONS: list[str] = [
6-
".txt", ".md", ".json", ".yaml", ".yml", ".csv",
7-
".py", ".js", ".ts", ".html", ".css", ".xml",
8-
".toml", ".ini", ".cfg", ".log",
9-
".sh", ".bash", ".ps1", ".bat",
6+
".txt",
7+
".md",
8+
".json",
9+
".yaml",
10+
".yml",
11+
".csv",
12+
".py",
13+
".js",
14+
".ts",
15+
".html",
16+
".css",
17+
".xml",
18+
".toml",
19+
".ini",
20+
".cfg",
21+
".log",
22+
".sh",
23+
".bash",
24+
".ps1",
25+
".bat",
1026
]
1127

1228
FILE_TYPE_LABELS: dict[str, str] = {

ContextPreloader/scripts/domain/detection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Pure detection functions (no I/O)."""
2+
23
from __future__ import annotations
34

45
from pathlib import Path
@@ -11,9 +12,7 @@ def is_url(path: str) -> bool:
1112
return path.startswith("http://") or path.startswith("https://")
1213

1314

14-
def detect_source_kind(
15-
path: str, text_extensions: list[str], forced_type: str
16-
) -> str:
15+
def detect_source_kind(path: str, text_extensions: list[str], forced_type: str) -> str:
1716
"""Detect how a source should be handled.
1817
1918
Returns: "text" | "binary" | "url"

ContextPreloader/scripts/domain/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Domain models for ContextPreloader."""
2+
23
from __future__ import annotations
34

45
from dataclasses import dataclass

ContextPreloader/scripts/infrastructure/config_repository.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Configuration file loading and saving."""
2+
23
from __future__ import annotations
34

45
import json
@@ -35,7 +36,9 @@ def load_config(config_path: str | Path) -> Config:
3536
raw_settings = data.get("settings", {})
3637
settings = Settings(
3738
encoding=raw_settings.get("encoding", DEFAULT_SETTINGS["encoding"]),
38-
max_lines_per_file=raw_settings.get("max_lines_per_file", DEFAULT_SETTINGS["max_lines_per_file"]),
39+
max_lines_per_file=raw_settings.get(
40+
"max_lines_per_file", DEFAULT_SETTINGS["max_lines_per_file"]
41+
),
3942
show_summary=raw_settings.get("show_summary", DEFAULT_SETTINGS["show_summary"]),
4043
url_timeout=raw_settings.get("url_timeout", DEFAULT_SETTINGS["url_timeout"]),
4144
mode=raw_settings.get("mode", DEFAULT_SETTINGS["mode"]),
@@ -47,15 +50,17 @@ def load_config(config_path: str | Path) -> Config:
4750
# Build Source list
4851
sources = []
4952
for s in data["sources"]:
50-
sources.append(Source(
51-
id=s.get("id", s.get("path", "")),
52-
label=s.get("label", s.get("path", "")),
53-
path=s["path"],
54-
type=s.get("type", "auto"),
55-
enabled=s.get("enabled", True),
56-
description=s.get("description", ""),
57-
priority=s.get("priority", "normal"),
58-
))
53+
sources.append(
54+
Source(
55+
id=s.get("id", s.get("path", "")),
56+
label=s.get("label", s.get("path", "")),
57+
path=s["path"],
58+
type=s.get("type", "auto"),
59+
enabled=s.get("enabled", True),
60+
description=s.get("description", ""),
61+
priority=s.get("priority", "normal"),
62+
)
63+
)
5964

6065
return Config(
6166
version=data.get("version", "1.0.0"),
@@ -117,15 +122,17 @@ def load_profile_sources(profile_path: str | Path) -> list[Source]:
117122

118123
sources = []
119124
for s in data.get("sources", []):
120-
sources.append(Source(
121-
id=s.get("id", s.get("path", "")),
122-
label=s.get("label", s.get("path", "")),
123-
path=s["path"],
124-
type=s.get("type", "auto"),
125-
enabled=s.get("enabled", True),
126-
description=s.get("description", ""),
127-
priority=s.get("priority", "normal"),
128-
))
125+
sources.append(
126+
Source(
127+
id=s.get("id", s.get("path", "")),
128+
label=s.get("label", s.get("path", "")),
129+
path=s["path"],
130+
type=s.get("type", "auto"),
131+
enabled=s.get("enabled", True),
132+
description=s.get("description", ""),
133+
priority=s.get("priority", "normal"),
134+
)
135+
)
129136
return sources
130137

131138

@@ -134,6 +141,4 @@ def list_profiles(profiles_dir: str | Path) -> list[str]:
134141
profiles_dir = Path(profiles_dir)
135142
if not profiles_dir.exists():
136143
return []
137-
return [
138-
p.stem for p in sorted(profiles_dir.glob("*.json"))
139-
]
144+
return [p.stem for p in sorted(profiles_dir.glob("*.json"))]

0 commit comments

Comments
 (0)