1616import json
1717import os
1818import sys
19- import tempfile
2019from pathlib import Path
21- from typing import TYPE_CHECKING , Any
20+ from typing import TYPE_CHECKING
2221from unittest .mock import MagicMock , patch
2322
2423import pytest
@@ -40,14 +39,12 @@ def temp_git_repo(tmp_path: Path) -> Generator[Path, None, None]:
4039 (git_dir / "HEAD" ).write_text ("ref: refs/heads/main" )
4140 # Include origin URL so git_repo name can be detected
4241 (git_dir / "config" ).write_text (
43- ' [core]\n \t repositoryformatversion = 0\n '
42+ " [core]\n \t repositoryformatversion = 0\n "
4443 '[remote "origin"]\n \t url = https://github.com/test-user/test-project.git\n '
4544 )
4645
4746 # Create a basic project structure
48- (tmp_path / "pyproject.toml" ).write_text (
49- '[project]\n name = "test-project"\n '
50- )
47+ (tmp_path / "pyproject.toml" ).write_text ('[project]\n name = "test-project"\n ' )
5148 (tmp_path / "src" ).mkdir ()
5249
5350 yield tmp_path
@@ -179,7 +176,9 @@ def test_session_start_json_output_format(
179176 """Test SessionStart hook produces valid JSON output."""
180177 from git_notes_memory .hooks .session_start_handler import _write_output
181178
182- context = "<memory_context project='test'><summary>Test</summary></memory_context>"
179+ context = (
180+ "<memory_context project='test'><summary>Test</summary></memory_context>"
181+ )
183182
184183 captured = io .StringIO ()
185184 with patch .object (sys , "stdout" , captured ):
@@ -319,7 +318,11 @@ def test_low_confidence_signals_skipped(self, hook_env_enabled: None) -> None:
319318 """Test that low-confidence signals result in SKIP action."""
320319 from git_notes_memory .hooks .capture_decider import CaptureDecider
321320 from git_notes_memory .hooks .config_loader import load_hook_config
322- from git_notes_memory .hooks .models import CaptureAction , CaptureSignal , SignalType
321+ from git_notes_memory .hooks .models import (
322+ CaptureAction ,
323+ CaptureSignal ,
324+ SignalType ,
325+ )
323326
324327 # Create a low-confidence signal
325328 signals = [
@@ -448,12 +451,12 @@ def test_session_flow_start_to_stop(
448451 self , temp_git_repo : Path , hook_env_enabled : None
449452 ) -> None :
450453 """Test complete session flow from start to stop."""
454+ from git_notes_memory .hooks .capture_decider import CaptureDecider
451455 from git_notes_memory .hooks .config_loader import load_hook_config
452456 from git_notes_memory .hooks .context_builder import ContextBuilder
453457 from git_notes_memory .hooks .models import CaptureAction
454458 from git_notes_memory .hooks .project_detector import detect_project
455459 from git_notes_memory .hooks .signal_detector import SignalDetector
456- from git_notes_memory .hooks .capture_decider import CaptureDecider
457460
458461 # 1. Session Start - detect project and build context
459462 project_info = detect_project (str (temp_git_repo ))
@@ -556,14 +559,14 @@ def test_stop_handles_invalid_transcript(
556559 result = _analyze_session (str (invalid ))
557560 assert result == []
558561
559- def test_all_hooks_output_continue_on_error (
560- self , hook_env_enabled : None
561- ) -> None :
562+ def test_all_hooks_output_continue_on_error (self , hook_env_enabled : None ) -> None :
562563 """Test that all hooks output continue:true even on errors."""
563564 # This verifies the non-blocking error handling pattern
564565
565566 # SessionStart - outputs empty on error (no hookSpecificOutput)
566- from git_notes_memory .hooks .session_start_handler import _write_output as ss_write
567+ from git_notes_memory .hooks .session_start_handler import (
568+ _write_output as ss_write ,
569+ )
567570
568571 captured = io .StringIO ()
569572 with patch .object (sys , "stdout" , captured ):
@@ -572,8 +575,8 @@ def test_all_hooks_output_continue_on_error(
572575 # SessionStart doesn't have continue field but hookSpecificOutput
573576
574577 # UserPromptSubmit - outputs continue:true
575- from git_notes_memory .hooks .user_prompt_handler import _write_output as up_write
576578 from git_notes_memory .hooks .models import CaptureAction
579+ from git_notes_memory .hooks .user_prompt_handler import _write_output as up_write
577580
578581 captured = io .StringIO ()
579582 with patch .object (sys , "stdout" , captured ):
0 commit comments