Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/add_licenses.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def process_repo(target: RepoTarget, headers: dict, dry_run: bool) -> tuple[str,
return name, "skipped (license exists)"

if dry_run:
license_text = build_mit_license(target.created_year)
year_range = str(target.created_year) if target.created_year == CURRENT_YEAR else f"{target.created_year}-{CURRENT_YEAR}"
return name, f"dry-run (would add LICENSE, copyright {year_range})"

Expand Down
3 changes: 2 additions & 1 deletion src/analyzers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def analyze(
repo_path: Path,
metadata: RepoMetadata,
github_client: GitHubClient | None = None,
) -> AnalyzerResult: ...
) -> AnalyzerResult:
raise NotImplementedError

def cache_inputs_hash(
self,
Expand Down
1 change: 0 additions & 1 deletion src/analyzers/community_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def analyze(
metadata: RepoMetadata,
github_client: GitHubClient | None = None,
) -> AnalyzerResult:
score = 0.0
findings: list[str] = []
details: dict = {}

Expand Down
7 changes: 3 additions & 4 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from src.terminology import ACTION_SYNC_CANONICAL_LABELS

# Emitted at most once per process when legacy flat invocation is used.
_LEGACY_WARNING_EMITTED: bool = False
_LEGACY_WARNING_EVENTS: set[str] = set()

DEFAULT_ANALYSIS_WORKERS = 1
MAX_ANALYSIS_WORKERS = 8
Expand Down Expand Up @@ -6533,10 +6533,9 @@ def _infer_subcommand_from_flags(args: argparse.Namespace) -> str:

def _emit_legacy_deprecation_warning(inferred: str) -> None:
"""Emit the deprecation warning at most once per process."""
global _LEGACY_WARNING_EMITTED
if _LEGACY_WARNING_EMITTED:
if "legacy-cli" in _LEGACY_WARNING_EVENTS:
return
_LEGACY_WARNING_EMITTED = True
_LEGACY_WARNING_EVENTS.add("legacy-cli")
warnings.warn(
f"Top-level CLI invocation is deprecated. "
f"Use `audit {inferred} --flag` instead. "
Expand Down
6 changes: 0 additions & 6 deletions src/maturity_tiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,8 @@ def _check_silver(repo: dict) -> list[str]:
def _check_gold(repo: dict) -> list[str]:
"""Return list of unmet Gold requirements (beyond Silver)."""
derived = repo.get("derived") or {}
risk = repo.get("risk") or {}
if not isinstance(derived, dict):
derived = {}
if not isinstance(risk, dict):
risk = {}

missing: list[str] = []

Expand Down Expand Up @@ -418,11 +415,8 @@ def _check_gold_with_sources(
) -> tuple[list[str], list[Literal["strict", "proxy"]]]:
"""Like _check_gold but also returns parallel source annotations."""
derived = repo.get("derived") or {}
risk = repo.get("risk") or {}
if not isinstance(derived, dict):
derived = {}
if not isinstance(risk, dict):
risk = {}

missing: list[str] = []
sources: list[Literal["strict", "proxy"]] = []
Expand Down
3 changes: 2 additions & 1 deletion src/narrative.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@


class NarrativeProvider(Protocol):
def generate(self, prompt: str, model: str, max_tokens: int) -> str: ...
def generate(self, prompt: str, model: str, max_tokens: int) -> str:
raise NotImplementedError


# ── Anthropic provider ───────────────────────────────────────────────────────
Expand Down
3 changes: 0 additions & 3 deletions src/operator_resolution_trend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19316,9 +19316,6 @@ def _class_trust_momentum_for_target(
if class_normalization_status == "applied" and momentum_status in {"reversing", "unstable"}:
softened_reason = "Recent class evidence is changing direction, so earlier class normalization is being softened back to candidate."
reverted_policy = target.get("pre_class_normalization_trust_policy", trust_policy)
reverted_reason = target.get(
"pre_class_normalization_trust_policy_reason", trust_policy_reason
)
if trust_policy == "act-with-review" and reverted_policy == "verify-first":
trust_policy = reverted_policy
trust_policy_reason = softened_reason
Expand Down
3 changes: 2 additions & 1 deletion src/semantic_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class Embedder(Protocol):
name: str
dimension: int

def embed(self, texts: list[str]) -> list[list[float]]: ...
def embed(self, texts: list[str]) -> list[list[float]]:
raise NotImplementedError


# ---------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/test_analyzer_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,11 @@ def counting_analyze(repo_path, metadata, github_client=None, **kwargs):
# First run — should call analyze() and populate cache.
r1 = run_with_cache(analyzer, repo, meta, None, sha, conn)
assert call_count == 1
first_run_count = call_count

# Second run — should hit cache and NOT call analyze() again.
r2 = run_with_cache(analyzer, repo, meta, None, sha, conn)
assert call_count == 1 # still 1!
assert call_count == first_run_count

assert r1.dimension == r2.dimension
assert r1.score == r2.score
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cli_subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,24 @@ def test_legacy_rewriter_leaves_serve_flag_unchanged(self):
assert is_legacy is False

def test_legacy_emits_deprecation_warning(self):
cli_module._LEGACY_WARNING_EMITTED = False
cli_module._LEGACY_WARNING_EVENTS.clear()
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
cli_module._emit_legacy_deprecation_warning("run")
assert any(issubclass(w.category, DeprecationWarning) for w in caught)
assert any("audit run" in str(w.message) for w in caught)
cli_module._LEGACY_WARNING_EMITTED = False
cli_module._LEGACY_WARNING_EVENTS.clear()

def test_legacy_warning_emits_once(self):
cli_module._LEGACY_WARNING_EMITTED = False
cli_module._LEGACY_WARNING_EVENTS.clear()
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
cli_module._emit_legacy_deprecation_warning("run")
cli_module._emit_legacy_deprecation_warning("run")
cli_module._emit_legacy_deprecation_warning("triage")
deprecations = [w for w in caught if issubclass(w.category, DeprecationWarning)]
assert len(deprecations) == 1
cli_module._LEGACY_WARNING_EMITTED = False
cli_module._LEGACY_WARNING_EVENTS.clear()

def test_legacy_skip_forks(self):
args = _parse_legacy("myuser", "--skip-forks")
Expand Down
4 changes: 4 additions & 0 deletions tests/test_plan_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ def test_archive_calls_apply_metadata_updates_with_right_shape(self) -> None:
]
ok, msg = dispatch_action(action, client=mock_client, owner="user", dry_run=False)

assert ok is True
assert msg == "archive applied to my-repo"
mock_apply.assert_called_once()
call_kwargs = mock_apply.call_args
# First positional arg is client, second is owner, third is updates list
Expand All @@ -715,6 +717,8 @@ def test_add_topics_calls_apply_metadata_updates(self) -> None:
]
ok, msg = dispatch_action(action, client=mock_client, owner="user", dry_run=False)

assert ok is True
assert msg == "add_topics applied to test-repo: ['python', 'cli', 'tool']"
mock_apply.assert_called_once()
call_kwargs = mock_apply.call_args
updates = call_kwargs[0][2]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class TestDraftReadmeApprovals:
"""Tests for draft-readme packet display and diff partial (Arc G S5.4)."""

def test_approvals_lists_both_draft_readme_records(self, output_dir: Path) -> None:
id1, id2 = _seed_draft_readme_records(output_dir)
_seed_draft_readme_records(output_dir)
app = create_app(output_dir=output_dir)
c = TestClient(app, raise_server_exceptions=True)
resp = c.get("/approvals")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def test_installed_package_version_resolvable() -> None:
pytest.skip(
"github-repo-auditor not installed in this environment — skipping runtime version check."
)

assert ver, "importlib.metadata.version() returned an empty string."
assert isinstance(ver, str), f"Expected str, got {type(ver)}"
else:
assert ver, "importlib.metadata.version() returned an empty string."
assert isinstance(ver, str), f"Expected str, got {type(ver)}"