[cleanup] clear radon C and deptry warnings on develop#38
Merged
Conversation
Drops radon complexity from C(16) → A(2) for the orchestrator, with each new sub-validator at A or B. Behaviour is unchanged: tests pass without modification (506 passed). Sub-validators introduced: - _validate_judgment_keys (extra-key rejection) - _validate_summary (presence + non-empty) - _validate_topics_list (count bounds, dupes, vocab membership) - _validate_primary_topic (presence, vocab membership, inclusion) The orchestrator still owns the early-return on a non-list topics value so callers see a single canonical error message.
Drops radon complexity from C(11) → A(3) by lifting the two list comprehensions into named helpers with substantive parsing logic: - _extract_archive_links: walks entities.urls, derives domain from expanded_url, filters missing entries - _extract_archive_media: prefers extended_entities.media over entities.media, normalises type (video/animated_gif → "video" else "photo") and picks media_url_https with expanded_url fallback Behaviour unchanged: all 506 tests pass without modification. The helpers carry the dict-navigation + conditional URL selection that the orchestrator no longer needs to spell out.
Drops radon complexity from C(13) → B(10) by lifting the topic-frequency accumulation (the nested loop + dict mutation, the only substantive non-rendering logic) into its own helper: - _count_topic_frequency(items) -> dict[str, int] The four corpus stat counters (bookmarks, own, noted, enriched) and the markdown line assembly stay inline — they are the function's actual job, and extracting them would be gold-plating. Radon now reports PASS (All A/B). Behaviour unchanged: all 506 tests pass.
scripts/import_chrome_session.py and scripts/import_safari_session.py import browser-cookie3 behind a guarded `try/except ImportError`. The existing config already silenced DEP001 (undeclared); DEP003 (transitive) was still surfacing because on some installs the package is pulled in indirectly via another extra. Chose the per-rule ignore over an `[project.optional-dependencies] sessions` group because the helper is install-on-demand outside the project's dependency surface — adding an extra would imply the project ships the integration, which it does not. Comment updated to explain both DEP001 and DEP003 are intentional. scripts/check.sh now reports ✅ Deptry: PASS.
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
Pure tech-debt cleanup. Clears the two warnings that survived on
develop:browser_cookie3helper silencedBehaviour unchanged. All 506 existing tests pass without modification — these are pure refactors plus a config tweak.
The four fixes
validate.validate_judgmentC(16) → A(2) — split into focused sub-validators (_validate_judgment_keys,_validate_summary,_validate_topics_list,_validate_primary_topic). Top-level orchestrator just concatenates errors and keeps the early-return on non-list topics.archive._archive_tweet_to_itemC(11) → A(3) — extracted two substantive parsing helpers:_extract_archive_links(entities.urls navigation + domain derivation) and_extract_archive_media(extended/legacy media source selection + type normalisation + URL fallback).generate._render_indexC(13) → B(10) — extracted_count_topic_frequency(the only non-rendering logic — nested loop + dict mutation). Stat counters and markdown emission stay inline; that's the function's actual job.pyproject.toml— addedDEP003 = ["browser_cookie3"]to[tool.deptry.per_rule_ignores]. The helper is guarded bytry/except ImportErrorinscripts/import_*_session.pyand was already covered by DEP001; DEP003 surfaces on installs where the package gets pulled in via another extra. Comment updated to explain both. Chose the per-rule ignore over an[project.optional-dependencies] sessionsgroup because the helper is install-on-demand and isn't part of the project's dependency surface.Proof —
scripts/check.shSUMMARYBefore (
develop)After (this branch)
Test plan
uv run pytest— 506 passed (unchanged count)uv run ruff check src/ tests/— All checks passeduv run ruff format --check src/ tests/— cleanuv run mypy --ignore-missing-imports src/— no issuesbash scripts/check.sh— ALL CRITICAL CHECKS PASSED, zero warnings