Skip to content

Convert Claude Code or Codex into the most intelligent Deep Research Agent. Collect, search, and synthesize web research into a persistent, searchable wiki that builds on itself. Hosted API + MCP: hyperresearch.ai

ruff: clean lint failures in v0.5.0 changeset

Jordan8d870ce52252
diff --git a/src/hyperresearch/cli/fetch.py b/src/hyperresearch/cli/fetch.py
index 9ec78f0..6e0e91d 100644
--- a/src/hyperresearch/cli/fetch.py
+++ b/src/hyperresearch/cli/fetch.py
@@ -145,7 +145,6 @@ def _detect_content_type(url: str, raw_content_type: str | None = None) -> str:
"""
if raw_content_type and "pdf" in raw_content_type.lower():
return "paper"
- u = url.lower()
domain = urlparse(url).netloc.lower()
path = urlparse(url).path.lower()
@@ -160,7 +159,7 @@ def _detect_content_type(url: str, raw_content_type: str | None = None) -> str:
return "code"
# Dataset portals that happen to live on .gov domains must win first
- if domain in ("data.gov", "data.gov.uk") or domain.startswith("data.") and (domain.endswith(".gov") or domain.endswith(".gov.uk") or domain.endswith(".europa.eu")):
+ if domain in ("data.gov", "data.gov.uk") or (domain.startswith("data.") and (domain.endswith(".gov") or domain.endswith(".gov.uk") or domain.endswith(".europa.eu"))):
return "dataset"
# Policy: gov domains, EU, regulator sites
diff --git a/src/hyperresearch/cli/lint.py b/src/hyperresearch/cli/lint.py
index 4ebcd88..f278204 100644
--- a/src/hyperresearch/cli/lint.py
+++ b/src/hyperresearch/cli/lint.py
@@ -185,8 +185,8 @@ def lint(
"severity": "error",
"note_id": "<vault>",
"message": (
- f"Most recent conformance audit returned status=failed. "
- f"Investigate the findings and re-run the auditor."
+ "Most recent conformance audit returned status=failed. "
+ "Investigate the findings and re-run the auditor."
),
})
@@ -230,7 +230,7 @@ def lint(
# broad — false matches are fine (they cause a re-check
# which passes harmlessly); missing a match is the failure
# mode we're guarding against.
- _KW_TO_RULE = [
+ kw_to_rule = [
# scaffold-prompt (verbatim prompt gospel rule)
("scaffold-prompt", "scaffold-prompt"),
("scaffold_prompt", "scaffold-prompt"),
@@ -305,7 +305,7 @@ def lint(
desc = (str(c.get("description", "")) + " " +
str(c.get("id", ""))).lower()
matched = None
- for kw, rule_name in _KW_TO_RULE:
+ for kw, rule_name in kw_to_rule:
if kw in desc:
matched = rule_name
break
diff --git a/src/hyperresearch/cli/note.py b/src/hyperresearch/cli/note.py
index 9f668f8..a3d8ba9 100644
--- a/src/hyperresearch/cli/note.py
+++ b/src/hyperresearch/cli/note.py
@@ -178,8 +178,8 @@ def note_show(
data = {
"id": row["id"], "title": row["title"], "path": row["path"],
"status": row["status"], "type": row["type"], "tags": tags,
- "tier": row["tier"] if "tier" in row.keys() else None,
- "content_type": row["content_type"] if "content_type" in row.keys() else None,
+ "tier": row["tier"] if "tier" in row else None, # noqa: SIM401 (sqlite3.Row has no .get())
+ "content_type": row["content_type"] if "content_type" in row else None, # noqa: SIM401
"created": row["created"], "updated": row["updated"],
"word_count": row["word_count"], "source": row["source"],
"parent": row["parent"], "summary": row["summary"],
@@ -343,8 +343,8 @@ def note_list(
"path": row["path"],
"status": row["status"],
"type": row["type"],
- "tier": row["tier"] if "tier" in row.keys() else None,
- "content_type": row["content_type"] if "content_type" in row.keys() else None,
+ "tier": row["tier"] if "tier" in row else None, # noqa: SIM401 (sqlite3.Row has no .get())
+ "content_type": row["content_type"] if "content_type" in row else None, # noqa: SIM401
"tags": tag_list,
"word_count": row["word_count"],
"summary": row["summary"],
@@ -548,6 +548,7 @@ def note_rm(
- any entries in the `assets` table and their files on disk
"""
import shutil
+
from hyperresearch.core.vault import Vault
vault = Vault.discover()
diff --git a/src/hyperresearch/core/patterns.py b/src/hyperresearch/core/patterns.py
index 174b660..926ccd4 100644
--- a/src/hyperresearch/core/patterns.py
+++ b/src/hyperresearch/core/patterns.py
@@ -88,6 +88,4 @@ def is_valid_wiki_link_target(ref: str) -> bool:
return False
if _SYMBOL_FOOTNOTE_RE.match(ref):
return False
- if _DOC_REF_PREFIX_RE.match(ref):
- return False
- return True
+ return not _DOC_REF_PREFIX_RE.match(ref)
diff --git a/src/hyperresearch/search/fts.py b/src/hyperresearch/search/fts.py
index c5602a9..a696f08 100644
--- a/src/hyperresearch/search/fts.py
+++ b/src/hyperresearch/search/fts.py
@@ -113,8 +113,8 @@ def search_fts(
"path": row["path"],
"status": row["status"],
"type": row["type"],
- "tier": row["tier"] if "tier" in row.keys() else None,
- "content_type": row["content_type"] if "content_type" in row.keys() else None,
+ "tier": row["tier"] if "tier" in row else None, # noqa: SIM401 (sqlite3.Row has no .get())
+ "content_type": row["content_type"] if "content_type" in row else None, # noqa: SIM401
"tags": tag_list,
"created": row["created"],
"updated": row["updated"],
diff --git a/src/hyperresearch/web/crawl4ai_provider.py b/src/hyperresearch/web/crawl4ai_provider.py
index fca0fe2..6ee3623 100644
--- a/src/hyperresearch/web/crawl4ai_provider.py
+++ b/src/hyperresearch/web/crawl4ai_provider.py
@@ -33,7 +33,7 @@ if sys.platform == "win32":
def _is_pdf_url(url: str) -> bool:
"""Check if URL likely points to a PDF."""
- from urllib.parse import urlparse, parse_qs
+ from urllib.parse import urlparse
parsed = urlparse(url.lower())
path = parsed.path
@@ -44,9 +44,7 @@ def _is_pdf_url(url: str) -> bool:
if "/pdf/" in path or "/pdfs/" in path:
return True
# arXiv PDF links
- if "arxiv.org" in parsed.netloc and ("/pdf/" in path or "/abs/" in path):
- return True
- return False
+ return "arxiv.org" in parsed.netloc and ("/pdf/" in path or "/abs/" in path)
def _looks_like_binary(text: str) -> bool:
@@ -58,10 +56,10 @@ def _looks_like_binary(text: str) -> bool:
pdf_markers = ("endstream", "endobj", "/Filter", "/FlateDecode", "stream\nx", "%PDF-")
if any(m in sample for m in pdf_markers):
return True
- # High ratio of actual binary/control chars — do NOT flag ord(c) > 127, as that would
+ # High ratio of actual binary/control chars - do NOT flag ord(c) > 127, as that would
# falsely reject valid CJK, Arabic, Cyrillic, and other non-ASCII text.
# Only flag: true control chars (< 0x20, excluding normal whitespace), the Unicode
- # replacement character (U+FFFD from bad decoding), and C1 controls (0x80–0x9F).
+ # replacement character (U+FFFD from bad decoding), and C1 controls (0x80-0x9F).
def _is_garbage(c: str) -> bool:
o = ord(c)
return (o < 0x20 and c not in '\t\n\r\f\v') or c == '\ufffd' or (0x80 <= o <= 0x9F)
diff --git a/tests/test_cli/test_lint.py b/tests/test_cli/test_lint.py
index dace659..1d1d94a 100644
--- a/tests/test_cli/test_lint.py
+++ b/tests/test_cli/test_lint.py
@@ -2,7 +2,6 @@
from __future__ import annotations
-import pytest
from typer.testing import CliRunner
from hyperresearch.cli.lint import app as lint_app
@@ -68,7 +67,7 @@ def test_scaffold_prompt_fails_when_header_missing(tmp_vault):
"1. Cosmology\n"
),
)
- code, out = _run_lint(tmp_vault, rule="scaffold-prompt")
+ _, out = _run_lint(tmp_vault, rule="scaffold-prompt")
import json
data = json.loads(out)
issues = data.get("data", {}).get("issues", [])
@@ -88,7 +87,7 @@ def test_scaffold_prompt_warns_when_quote_too_short(tmp_vault):
"- thing\n"
),
)
- code, out = _run_lint(tmp_vault, rule="scaffold-prompt")
+ _, out = _run_lint(tmp_vault, rule="scaffold-prompt")
import json
data = json.loads(out)
issues = data.get("data", {}).get("issues", [])
@@ -131,7 +130,7 @@ def test_provenance_rooted_tree_passes_with_valid_chain(tmp_vault):
_write_source(tmp_vault, "Child C", "child-c", body="*Suggested by [[seed-two]] — reply*\n\nCritical response.")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="provenance")
+ _, out = _run_lint(tmp_vault, rule="provenance")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "provenance"]
@@ -144,7 +143,7 @@ def test_provenance_fails_when_all_sources_are_seeds(tmp_vault):
_write_source(tmp_vault, f"Source {i}", f"source-{i}")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="provenance")
+ _, out = _run_lint(tmp_vault, rule="provenance")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "provenance"]
@@ -162,7 +161,7 @@ def test_provenance_fails_on_dangling_breadcrumb(tmp_vault):
_write_source(tmp_vault, "Child D", "child-d", body="*Suggested by [[seed-one]] — real*\n")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="provenance")
+ _, out = _run_lint(tmp_vault, rule="provenance")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "provenance"]
@@ -177,7 +176,7 @@ def test_provenance_small_corpus_is_skipped(tmp_vault):
_write_source(tmp_vault, f"Source {i}", f"source-{i}")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="provenance")
+ _, out = _run_lint(tmp_vault, rule="provenance")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "provenance"]
@@ -200,7 +199,7 @@ def test_provenance_errors_on_under_30pct_non_seed_ratio(tmp_vault):
_write_source(tmp_vault, f"Source {i}", f"source-{i}", body=body)
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="provenance")
+ _, out = _run_lint(tmp_vault, rule="provenance")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "provenance"]
@@ -217,7 +216,7 @@ def test_orphaned_raw_files_flags_disk_leak(tmp_vault):
(raw_dir / "orphan-note.pdf").write_bytes(b"%PDF-1.4 dummy")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="orphaned-raw-files")
+ _, out = _run_lint(tmp_vault, rule="orphaned-raw-files")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "orphaned-raw-files"]
@@ -258,7 +257,7 @@ def test_audit_gate_blocks_unresolved_criticals(tmp_vault):
}
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -284,7 +283,7 @@ def test_audit_gate_passes_when_all_criticals_fixed(tmp_vault):
}
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -320,7 +319,7 @@ def test_audit_gate_uses_most_recent_conformance_run(tmp_vault):
},
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -344,7 +343,7 @@ def test_audit_gate_fails_when_only_comprehensiveness_run_exists(tmp_vault):
}
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -375,7 +374,7 @@ def test_audit_gate_surfaces_important_findings_as_info(tmp_vault):
}
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -423,7 +422,7 @@ def test_audit_gate_catches_self_certification_on_provenance(tmp_vault):
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = data.get("data", {}).get("issues", [])
@@ -471,7 +470,7 @@ def test_audit_gate_no_self_cert_when_fix_genuinely_landed(tmp_vault):
]
})
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = data.get("data", {}).get("issues", [])
@@ -486,7 +485,7 @@ def test_audit_gate_handles_malformed_file(tmp_vault):
audit_path = tmp_vault.root / "research" / "audit_findings.json"
audit_path.parent.mkdir(parents=True, exist_ok=True)
audit_path.write_text("{ not valid json }", encoding="utf-8")
- code, out = _run_lint(tmp_vault, rule="audit-gate")
+ _, out = _run_lint(tmp_vault, rule="audit-gate")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "audit-gate"]
@@ -510,7 +509,7 @@ def test_orphaned_raw_files_ignores_matched_raw(tmp_vault):
(raw_dir / "real-pdf-note.pdf").write_bytes(b"%PDF-1.4 dummy")
tmp_vault.auto_sync()
- code, out = _run_lint(tmp_vault, rule="orphaned-raw-files")
+ _, out = _run_lint(tmp_vault, rule="orphaned-raw-files")
import json
data = json.loads(out)
issues = [i for i in data.get("data", {}).get("issues", []) if i.get("rule") == "orphaned-raw-files"]
diff --git a/tests/test_core/test_hooks.py b/tests/test_core/test_hooks.py
index a24b54d..c5c27c7 100644
--- a/tests/test_core/test_hooks.py
+++ b/tests/test_core/test_hooks.py
@@ -2,8 +2,6 @@
from __future__ import annotations
-from pathlib import Path
-
from hyperresearch.core.hooks import _SKILL_FILES, _install_research_skill