diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8cf01a4..3904864 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: pip install bandit pip-audit ruff --break-system-packages - name: Ruff lint - run: ruff check . || true + run: ruff check . - name: Bandit (advisory) run: bandit -r . -q || true @@ -61,7 +61,7 @@ jobs: run: | if [ -d tests ] || ls test_*.py *_test.py 2>/dev/null; then pip install pytest --break-system-packages - pytest -q || true + pytest -q else echo "No tests found — skip" fi diff --git a/scripts/auto-cherry-pick.py b/scripts/auto-cherry-pick.py old mode 100644 new mode 100755 index f4b4128..1d011e2 --- a/scripts/auto-cherry-pick.py +++ b/scripts/auto-cherry-pick.py @@ -171,9 +171,7 @@ def text_is_factual(text: str) -> bool: return True if DATA_PHONE.search(text) or DATA_MONEY.search(text) or DATA_EMAIL.search(text): return True - if DATA_ADDRESS.search(text) and DATA_DATE.search(text): - return True - return False + return bool(DATA_ADDRESS.search(text) and DATA_DATE.search(text)) def looks_conversational(text: str) -> bool: @@ -184,9 +182,7 @@ def looks_conversational(text: str) -> bool: if text.count("?") >= 2 and len(text) < 500: return True # Short back-and-forth without hard facts. - if len(text) < 80 and not has_data_signals(text): - return True - return False + return len(text) < 80 and not has_data_signals(text) def is_name_list_message(text: str) -> bool: @@ -295,9 +291,7 @@ def msg_selection( if latest_draft_files and fid in latest_draft_files: files[fid] = True continue - if is_doc(f) or informative_filename(f.get("name") or ""): - files[fid] = True - elif is_image(f) and informative_image(f, text): + if is_doc(f) or informative_filename(f.get("name") or "") or is_image(f) and informative_image(f, text): files[fid] = True return { "action": "import", diff --git a/scripts/build-test-fixture.py b/scripts/build-test-fixture.py old mode 100644 new mode 100755 diff --git a/scripts/prepare-export.py b/scripts/prepare-export.py old mode 100644 new mode 100755 diff --git a/server.py b/server.py index 58b6984..e406f1f 100755 --- a/server.py +++ b/server.py @@ -9,8 +9,8 @@ import json import mimetypes import os import sys -import zipfile import xml.etree.ElementTree as ET +import zipfile from datetime import datetime, timezone from http import HTTPStatus from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer @@ -115,7 +115,7 @@ class ReviewHandler(BaseHTTPRequestHandler): export: SlackExport manifest_path: Path - def log_message(self, format: str, *args) -> None: # noqa: A003 + def log_message(self, format: str, *args) -> None: if os.environ.get("SLACK_IMPORT_QUIET") != "1": super().log_message(format, *args) @@ -166,14 +166,14 @@ class ReviewHandler(BaseHTTPRequestHandler): except json.JSONDecodeError: return None - def do_OPTIONS(self) -> None: # noqa: N802 + def do_OPTIONS(self) -> None: self.send_response(HTTPStatus.NO_CONTENT) self.send_header("Access-Control-Allow-Origin", "*") self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS") self.send_header("Access-Control-Allow-Headers", "Content-Type") self.end_headers() - def do_GET(self) -> None: # noqa: N802 + def do_GET(self) -> None: parsed = urlparse(self.path) path = parsed.path qs = parse_qs(parsed.query) @@ -364,7 +364,7 @@ class ReviewHandler(BaseHTTPRequestHandler): self.send_error(HTTPStatus.NOT_FOUND) - def do_POST(self) -> None: # noqa: N802 + def do_POST(self) -> None: parsed = urlparse(self.path) if parsed.path != "/api/manifest": self.send_error(HTTPStatus.NOT_FOUND) diff --git a/slack_export.py b/slack_export.py index 7102477..347e5b8 100644 --- a/slack_export.py +++ b/slack_export.py @@ -9,7 +9,6 @@ from datetime import datetime, timezone from pathlib import Path from typing import Any - DEFAULT_EXPORT = Path.home() / "Downloads" / "slack-export" diff --git a/tests/test_cherry_pick.py b/tests/test_cherry_pick.py index e655e31..1b87366 100644 --- a/tests/test_cherry_pick.py +++ b/tests/test_cherry_pick.py @@ -60,7 +60,7 @@ def test_wilson_not_in_auto_channels(cherry_pick): def test_dry_run_pick_count(cherry_pick, export, empty_manifest, tmp_path, monkeypatch): - path, manifest = empty_manifest + _path, manifest = empty_manifest monkeypatch.setattr(cherry_pick, "MANIFEST_PATH", tmp_path / "manifest.json") monkeypatch.setattr(cherry_pick, "DEFAULT_EXPORT", export.paths.root) diff --git a/tests/test_coverage_gaps.py b/tests/test_coverage_gaps.py index 9667d4b..5721e6b 100644 --- a/tests/test_coverage_gaps.py +++ b/tests/test_coverage_gaps.py @@ -2,12 +2,11 @@ from __future__ import annotations -import io import json import urllib.error import urllib.request -import zipfile from pathlib import Path + import pytest @@ -117,9 +116,10 @@ def test_manifest_post_skips_non_dict_user(api): def test_safe_export_path_rejects_dotdot(): + from unittest.mock import Mock + import server from slack_export import SlackExport - from unittest.mock import Mock root = Path(__file__).resolve().parents[1] / "tests/fixtures/mini-export" handler = Mock(spec=server.ReviewHandler) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 530466e..f8a36cd 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -5,11 +5,16 @@ from __future__ import annotations import io import json import zipfile -from pathlib import Path import pytest -from slack_export import SlackExport, load_json, resolve_paths, slack_ts_to_iso, user_display +from slack_export import ( + SlackExport, + load_json, + resolve_paths, + slack_ts_to_iso, + user_display, +) def test_slack_ts_to_iso(): diff --git a/tests/test_prepare_export.py b/tests/test_prepare_export.py index 695814f..8b38ac6 100644 --- a/tests/test_prepare_export.py +++ b/tests/test_prepare_export.py @@ -3,8 +3,6 @@ from __future__ import annotations import json -import shutil -import sys from pathlib import Path import pytest diff --git a/tests/test_preset_skips.py b/tests/test_preset_skips.py index c5d53a7..ea649d7 100644 --- a/tests/test_preset_skips.py +++ b/tests/test_preset_skips.py @@ -6,8 +6,6 @@ import importlib.util import json from pathlib import Path -import pytest - REPO = Path(__file__).resolve().parents[1] diff --git a/tests/test_server.py b/tests/test_server.py index 2ede8aa..ad29114 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -2,8 +2,6 @@ from __future__ import annotations -import json - def test_health(api): data = api["get"]("/api/health") diff --git a/tests/test_slack_export_extended.py b/tests/test_slack_export_extended.py index bfabd87..be89be2 100644 --- a/tests/test_slack_export_extended.py +++ b/tests/test_slack_export_extended.py @@ -3,7 +3,6 @@ from __future__ import annotations import json -from pathlib import Path import pytest