Skip to content

Commit 3d99f73

Browse files
vintaclaude
andcommitted
style(website): apply ruff format
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 432a1f4 commit 3d99f73

4 files changed

Lines changed: 29 additions & 43 deletions

File tree

website/fetch_github_stars.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pathlib import Path
1212

1313
import httpx
14-
1514
from build import extract_github_repo, load_stars
1615

1716
CACHE_MAX_AGE_HOURS = 12
@@ -53,10 +52,7 @@ def build_graphql_query(repos: Sequence[str]) -> str:
5352
owner, name = repo.split("/", 1)
5453
if not GITHUB_OWNER_RE.match(owner) or not GITHUB_NAME_RE.match(name):
5554
continue
56-
parts.append(
57-
f'repo_{i}: repository(owner: "{owner}", name: "{name}") '
58-
f"{{ stargazerCount owner {{ login }} defaultBranchRef {{ target {{ ... on Commit {{ committedDate }} }} }} }}"
59-
)
55+
parts.append(f'repo_{i}: repository(owner: "{owner}", name: "{name}") {{ stargazerCount owner {{ login }} defaultBranchRef {{ target {{ ... on Commit {{ committedDate }} }} }} }}')
6056
if not parts:
6157
return ""
6258
return "query { " + " ".join(parts) + " }"

website/readme_parser.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,22 @@ def _parse_list_entries(
229229
if sub_inline:
230230
sub_link = _find_child(sub_inline, "link")
231231
if sub_link:
232-
also_see.append(AlsoSee(
233-
name=render_inline_text(sub_link.children),
234-
url=_href(sub_link),
235-
))
236-
237-
entries.append(ParsedEntry(
238-
name=name,
239-
url=url,
240-
description=desc_html,
241-
also_see=also_see,
242-
subcategory=subcategory,
243-
))
232+
also_see.append(
233+
AlsoSee(
234+
name=render_inline_text(sub_link.children),
235+
url=_href(sub_link),
236+
)
237+
)
238+
239+
entries.append(
240+
ParsedEntry(
241+
name=name,
242+
url=url,
243+
description=desc_html,
244+
also_see=also_see,
245+
subcategory=subcategory,
246+
)
247+
)
244248

245249
return entries
246250

@@ -275,7 +279,6 @@ def _build_section(name: str, body: list[SyntaxTreeNode]) -> ParsedSection:
275279
)
276280

277281

278-
279282
def _is_bold_marker(node: SyntaxTreeNode) -> str | None:
280283
"""Detect a bold-only paragraph used as a group marker.
281284
@@ -321,11 +324,13 @@ def flush_group() -> None:
321324
nonlocal current_group_name, current_group_cats
322325
if current_group_cats:
323326
name = current_group_name or "Other"
324-
groups.append(ParsedGroup(
325-
name=name,
326-
slug=slugify(name),
327-
categories=list(current_group_cats),
328-
))
327+
groups.append(
328+
ParsedGroup(
329+
name=name,
330+
slug=slugify(name),
331+
categories=list(current_group_cats),
332+
)
333+
)
329334
current_group_name = None
330335
current_group_cats = []
331336

website/tests/test_fetch_github_stars.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,12 @@ def test_extracts_owner_repo_from_github_url(self):
1717
assert result == {"psf/requests"}
1818

1919
def test_multiple_repos(self):
20-
readme = (
21-
"* [requests](https://github.com/psf/requests) - HTTP.\n"
22-
"* [flask](https://github.com/pallets/flask) - Micro."
23-
)
20+
readme = "* [requests](https://github.com/psf/requests) - HTTP.\n* [flask](https://github.com/pallets/flask) - Micro."
2421
result = extract_github_repos(readme)
2522
assert result == {"psf/requests", "pallets/flask"}
2623

2724
def test_deduplicates(self):
28-
readme = (
29-
"* [a](https://github.com/org/repo) - A.\n"
30-
"* [b](https://github.com/org/repo) - B."
31-
)
25+
readme = "* [a](https://github.com/org/repo) - A.\n* [b](https://github.com/org/repo) - B."
3226
result = extract_github_repos(readme)
3327
assert result == {"org/repo"}
3428

website/tests/test_readme_parser.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,7 @@ def _content_nodes(md_text: str) -> list[SyntaxTreeNode]:
350350

351351
class TestParseSectionEntries:
352352
def test_flat_entries(self):
353-
nodes = _content_nodes(
354-
"- [django](https://example.com/d) - A web framework.\n"
355-
"- [flask](https://example.com/f) - A micro framework.\n"
356-
)
353+
nodes = _content_nodes("- [django](https://example.com/d) - A web framework.\n- [flask](https://example.com/f) - A micro framework.\n")
357354
entries = _parse_section_entries(nodes)
358355
assert len(entries) == 2
359356
assert entries[0]["name"] == "django"
@@ -370,13 +367,7 @@ def test_link_only_entry(self):
370367
assert entries[0]["description"] == ""
371368

372369
def test_subcategorized_entries(self):
373-
nodes = _content_nodes(
374-
"- Algorithms\n"
375-
" - [algos](https://x.com/a) - Algo lib.\n"
376-
" - [sorts](https://x.com/s) - Sort lib.\n"
377-
"- Design Patterns\n"
378-
" - [patterns](https://x.com/p) - Pattern lib.\n"
379-
)
370+
nodes = _content_nodes("- Algorithms\n - [algos](https://x.com/a) - Algo lib.\n - [sorts](https://x.com/s) - Sort lib.\n- Design Patterns\n - [patterns](https://x.com/p) - Pattern lib.\n")
380371
entries = _parse_section_entries(nodes)
381372
assert len(entries) == 3
382373
assert entries[0]["name"] == "algos"
@@ -432,7 +423,7 @@ def test_entry_count_includes_also_see(self):
432423
assert cats[0]["entry_count"] == 3
433424

434425
def test_description_html_escapes_xss(self):
435-
nodes = _content_nodes('- [lib](https://x.com) - A <script>alert(1)</script> lib.\n')
426+
nodes = _content_nodes("- [lib](https://x.com) - A <script>alert(1)</script> lib.\n")
436427
entries = _parse_section_entries(nodes)
437428
assert "<script>" not in entries[0]["description"]
438429
assert "&lt;script&gt;" in entries[0]["description"]

0 commit comments

Comments
 (0)