Skip to content

Commit 4c6dd13

Browse files
committed
ruff format
1 parent ffcf5bd commit 4c6dd13

File tree

2 files changed

+30
-47
lines changed

2 files changed

+30
-47
lines changed

changeset/changelog.py

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ def get_git_info() -> dict:
4444
# Get the current commit hash
4545
try:
4646
result = subprocess.run(
47-
["git", "rev-parse", "HEAD"],
48-
capture_output=True,
49-
text=True,
50-
check=True
47+
["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True
5148
)
5249
info["commit"] = result.stdout.strip()[:7] # Short hash
5350
except Exception:
@@ -59,7 +56,7 @@ def get_git_info() -> dict:
5956
["git", "remote", "get-url", "origin"],
6057
capture_output=True,
6158
text=True,
62-
check=True
59+
check=True,
6360
)
6461
remote_url = result.stdout.strip()
6562
# Extract owner/repo from URL
@@ -95,11 +92,7 @@ def get_pr_metadata() -> dict:
9592
return metadata
9693

9794

98-
def format_changelog_entry(
99-
entry: dict,
100-
config: dict,
101-
pr_metadata: dict
102-
) -> str:
95+
def format_changelog_entry(entry: dict, config: dict, pr_metadata: dict) -> str:
10396
"""Format a single changelog entry with PR and commit info."""
10497
description = entry["description"]
10598
pr_number = pr_metadata.get("pr_number")
@@ -129,11 +122,7 @@ def format_changelog_entry(
129122

130123

131124
def generate_changelog_section(
132-
package: str,
133-
new_version: str,
134-
entries: list[dict],
135-
config: dict,
136-
pr_metadata: dict
125+
package: str, new_version: str, entries: list[dict], config: dict, pr_metadata: dict
137126
) -> str:
138127
"""Generate changelog section for a package version."""
139128
lines = []
@@ -159,7 +148,7 @@ def generate_changelog_section(
159148
type_label = {
160149
"major": "Major Changes",
161150
"minor": "Minor Changes",
162-
"patch": "Patch Changes"
151+
"patch": "Patch Changes",
163152
}.get(change_type, f"{change_type.capitalize()} Changes")
164153

165154
lines.append(f"### {type_label}")
@@ -175,9 +164,7 @@ def generate_changelog_section(
175164

176165

177166
def update_or_create_changelog(
178-
changelog_path: Path,
179-
package_name: str,
180-
new_section: str
167+
changelog_path: Path, package_name: str, new_section: str
181168
) -> bool:
182169
"""Update or create a changelog file."""
183170
if changelog_path.exists():
@@ -264,11 +251,9 @@ def process_changesets_for_changelog() -> tuple[list[dict], str]:
264251
if package not in package_changes:
265252
package_changes[package] = {"changes": [], "descriptions": []}
266253
package_changes[package]["changes"].append(change_type)
267-
package_changes[package]["descriptions"].append({
268-
"type": change_type,
269-
"description": desc,
270-
"changeset": filepath.name
271-
})
254+
package_changes[package]["descriptions"].append(
255+
{"type": change_type, "description": desc, "changeset": filepath.name}
256+
)
272257

273258
# Process each package
274259
package_updates = []
@@ -288,24 +273,22 @@ def process_changesets_for_changelog() -> tuple[list[dict], str]:
288273

289274
# Generate changelog content
290275
changelog_content = generate_changelog_section(
291-
package,
292-
new_version,
293-
info["descriptions"],
294-
config,
295-
pr_metadata
276+
package, new_version, info["descriptions"], config, pr_metadata
296277
)
297278

298279
# Find changelog path (same directory as pyproject.toml)
299280
changelog_path = pyproject_path.parent / "CHANGELOG.md"
300281

301-
package_updates.append({
302-
"package": package,
303-
"version": new_version,
304-
"current_version": current_version,
305-
"changelog_path": changelog_path,
306-
"changelog_content": changelog_content,
307-
"pyproject_path": pyproject_path,
308-
})
282+
package_updates.append(
283+
{
284+
"package": package,
285+
"version": new_version,
286+
"current_version": current_version,
287+
"changelog_path": changelog_path,
288+
"changelog_content": changelog_content,
289+
"pyproject_path": pyproject_path,
290+
}
291+
)
309292

310293
# Generate PR description
311294
pr_description = generate_pr_description(package_updates)
@@ -335,35 +318,33 @@ def main(dry_run: bool, output_pr_description: str):
335318
click.style(f"Found updates for {len(package_updates)} package(s):", fg="green")
336319
)
337320
for update in package_updates:
338-
current = update['current_version']
339-
new = update['version']
321+
current = update["current_version"]
322+
new = update["version"]
340323
click.echo(f" 📦 {update['package']}: {current}{new}")
341324

342325
if dry_run:
343326
click.echo(
344327
click.style("\n🔍 Dry run mode - no changes will be made", fg="yellow")
345328
)
346-
click.echo("\n" + "="*60)
329+
click.echo("\n" + "=" * 60)
347330
click.echo(click.style("PR Description:", fg="cyan"))
348-
click.echo("="*60)
331+
click.echo("=" * 60)
349332
click.echo(pr_description)
350-
click.echo("="*60)
333+
click.echo("=" * 60)
351334

352335
for update in package_updates:
353336
click.echo(
354337
click.style(f"\nChangelog for {update['changelog_path']}:", fg="cyan")
355338
)
356-
click.echo("-"*60)
339+
click.echo("-" * 60)
357340
click.echo(update["changelog_content"])
358-
click.echo("-"*60)
341+
click.echo("-" * 60)
359342
return
360343

361344
# Update changelog files
362345
for update in package_updates:
363346
success = update_or_create_changelog(
364-
update["changelog_path"],
365-
update["package"],
366-
update["changelog_content"]
347+
update["changelog_path"], update["package"], update["changelog_content"]
367348
)
368349

369350
if success:

changeset/changeset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ def changelog(dry_run: bool, output_pr_description: str):
475475
import sys
476476

477477
from changeset.changelog import main as changelog_main
478+
478479
original_argv = sys.argv
479480
try:
480481
sys.argv = ["changelog"]
@@ -641,6 +642,7 @@ def check_changeset(skip_ci: bool):
641642
import sys
642643

643644
from changeset.check_changeset import main as check_main
645+
644646
original_argv = sys.argv
645647
try:
646648
sys.argv = ["check-changeset"]

0 commit comments

Comments
 (0)