chore: simplify website/ Python and polish sponsors section#3076
Merged
chore: simplify website/ Python and polish sponsors section#3076
Conversation
…build_graphql_query The empty-parts check after the loop makes the upfront `if not repos: return ""` guard redundant. Co-Authored-By: Claude <noreply@anthropic.com>
State reset (current_group_name = None, current_group_cats = []) was duplicated in both branches of the early-return guard. Move it after the conditional so it runs exactly once regardless of path. Co-Authored-By: Claude <noreply@anthropic.com>
Python 3.11 introduced datetime.UTC as a cleaner alias for datetime.timezone.utc. Both build.py and fetch_github_stars.py are updated to use the shorter form. Co-Authored-By: Claude <noreply@anthropic.com>
… fetch_batch client is the only non-first param and is always required, so the * separator adds no clarity. Update the call site accordingly. Co-Authored-By: Claude <noreply@anthropic.com>
Remove internal str->Path conversion; callers and tests now pass Path objects directly. Co-Authored-By: Claude <noreply@anthropic.com>
…tion/ParsedGroup Replace loose list[dict] annotations with concrete TypedDicts imported from readme_parser so ty can verify call-site compatibility. Co-Authored-By: Claude <noreply@anthropic.com>
…to dict[str, dict] Cache-write shape mismatches the TypedDict and callers mix .get() and direct access, so the stricter type was providing false safety. Using dict[str, dict] accurately reflects the actual runtime contract. Co-Authored-By: Claude <noreply@anthropic.com>
Extracts a _href(link) helper that returns link.attrGet('href') narrowed
to str (falling back to '') instead of the raw str|int|float|None union.
Replaces all four attrGet('href') or '' call sites with _href(), fixing
ty errors where the widened union leaked into TypedDict url fields.
Co-Authored-By: Claude <noreply@anthropic.com>
…line, "link") The private helper duplicated _find_child with a hardcoded type filter. Remove it and call the general helper directly at both call sites. Co-Authored-By: Claude <noreply@anthropic.com>
The helper was only called once and the bool(inline.children) guard was redundant: first_link being non-None already implies inline.children is non-empty. Co-Authored-By: Claude <noreply@anthropic.com>
The helper only appeared once and the logic is two lines, so the named function added indirection without clarity. Removed the four dedicated unit tests that covered the function directly. Co-Authored-By: Claude <noreply@anthropic.com>
…s.batched Use itertools.batched (stdlib since Python 3.12, targeted by this project) instead of manual range(0, N, BATCH_SIZE) slicing. Loosen fetch_batch, build_graphql_query, and parse_graphql_response signatures from list[str] to Sequence[str] since batched yields tuples. Co-Authored-By: Claude <noreply@anthropic.com>
Use timedelta(hours=CACHE_MAX_AGE_HOURS) so the cache-age check reads at the intended hours unit directly, removing the conversion arithmetic. Co-Authored-By: Claude <noreply@anthropic.com>
Collapse the if-seen/else-new branches so the category/group/subcategory merge logic runs once per entry unconditionally, appending to empty lists on first sight instead of duplicating the append logic in the else branch. Annotate seen and entries as dict[str, Any] so ty can resolve the mixed value types (str, list, None) in each entry dict. Co-Authored-By: Claude <noreply@anthropic.com>
…r_inline helper Merge the two inline-renderer implementations into a single _render_inline(children, *, html) function that handles both output modes. The original public functions become one-line wrappers so all dispatch logic lives in one place. Also aligns html_inline handling: the html=True path now escapes the raw content instead of silently dropping it in the plain-text path. Co-Authored-By: Claude <noreply@anthropic.com>
Eliminate the redundant _find_link_deep precheck by merging the two walks over inline.children into one loop that simultaneously locates the link and records its top-level index. Co-Authored-By: Claude <noreply@anthropic.com>
Replace os.path.join + manual open() with Path(__file__).resolve().parents[2] and Path.read_text() for locating and reading README.md. Co-Authored-By: Claude <noreply@anthropic.com>
Override font-size to var(--text-lg) inside .sponsor-meta so the Sponsors heading is larger, while the shared .section-label class remains --text-sm everywhere else. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…ration Swap the border-bottom + padding-bottom fake underline on .sponsor-become for a native text-decoration underline with text-underline-offset so the line hugs the text at the same distance as the hero @vinta/@JinyangWang27 links, rather than sitting a fixed 0.2rem gap away. Co-Authored-By: Claude <noreply@anthropic.com>
Swaps --line-strong for --accent-underline on the 'Become a sponsor' text-decoration-color so the underline matches the tan hover underline on project-name links like thealgorithms. Co-Authored-By: Claude <noreply@anthropic.com>
…-line-strong at rest Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
website/(17 commits): deleted dead code, tightened types, modernized syntax. Tests: 117 → 113 (4format_stars_shorttests removed along with the inlined function).uvx ty check website/: 15 diagnostics → 0.Python cleanup highlights
_find_first_link,_is_leading_link,format_stars_short) and staleStarDataTypedDictextract_entriesparameter types,build()now takesPath,load_starsreturnsdict[str, dict]_hrefhelper to narrowattrGet("href")return typeitertools.batched(3.13 stdlib)timedeltainstead oftotal_seconds()/3600render_inline_html/render_inline_textinto a shared_render_inlinehelper_parse_sponsor_itemdouble-walk into a single passdatetime.now(timezone.utc)→datetime.now(UTC)test_readme_parserto usepathlibSponsors styling
.sponsor-meta .section-label:--text-sm→--text-lg<span class="sponsor-become-arrow">+ orphaned CSS rules.sponsor-become:border-bottom+padding-bottom→text-decoration: underlinewithtext-underline-offset: 0.2em--accent-underline(lighter tan)Test plan
uv run pytest— 113 passinguvx ty check website/— all checks passedmake preview)🤖 Generated with Claude Code