Repository navigation
feat: add handover documentation - #7
Conversation
|
|
||
| from call2action.handover_pipeline import HandoverPipeline | ||
|
|
||
| handover_pipeline = HandoverPipeline() |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the problem, we should remove the redundant assignment to the variable handover_pipeline on line 70 in examples.py. Since the value assigned there is immediately overwritten before any usage, it serves no purpose and can be safely deleted. We should only remove the assignment statement on line 70, leaving surrounding comments and code untouched to maintain the context of the examples and avoid any change in functionality or documentation.
| @@ -67,7 +67,6 @@ | ||
|
|
||
| from call2action.handover_pipeline import HandoverPipeline | ||
|
|
||
| handover_pipeline = HandoverPipeline() | ||
|
|
||
| # Generate handover from all videos in a directory | ||
| # report = handover_pipeline.generate_handover("path/to/videos/") |
| openai_model="gpt-4o", # Use more powerful model for better analysis | ||
| ) | ||
|
|
||
| handover_pipeline = HandoverPipeline(settings=custom_settings) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the "unused local variable" warning, rename the variable handover_pipeline on line 90 to a name that clearly indicates it is intentionally unused. CodeQL recommends names with unused in them (such as unused_handover_pipeline). This preserves the assignment (which may have side effects if the constructor does), but makes it clear to readers and static analysis tools that the variable is unused on purpose—likely for illustrative, documentation, or example purposes. Only change line 90 in the file examples.py as that's the assignment flagged; do not modify other places unless the variable is referenced elsewhere (it's not here).
| @@ -87,7 +87,7 @@ | ||
| openai_model="gpt-4o", # Use more powerful model for better analysis | ||
| ) | ||
|
|
||
| handover_pipeline = HandoverPipeline(settings=custom_settings) | ||
| unused_handover_pipeline = HandoverPipeline(settings=custom_settings) | ||
| # report = handover_pipeline.generate_handover("path/to/videos/") | ||
|
|
||
| print("You can customize output directory and filename for handover reports.\n") |
| whisper_device="cuda", # Use GPU for even faster processing | ||
| ) | ||
|
|
||
| fast_pipeline = HandoverPipeline(settings=parallel_settings) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To address this issue in the most straightforward way without altering existing functionality, we should remove the assignment to fast_pipeline on line 105 entirely. If future users want to follow the example, they can uncomment the sample code below as needed. There is no need to keep the assignment in the source, as there are no side effects or documentation purposes tied to it.
Edit the examples.py file:
- Delete the line
fast_pipeline = HandoverPipeline(settings=parallel_settings)on line 105. - No imports, method signatures, or additional definitions need to be changed; only this line is affected.
| @@ -102,7 +102,7 @@ | ||
| whisper_device="cuda", # Use GPU for even faster processing | ||
| ) | ||
|
|
||
| fast_pipeline = HandoverPipeline(settings=parallel_settings) | ||
| # fast_pipeline = HandoverPipeline(settings=parallel_settings) | ||
| # report = fast_pipeline.generate_handover("path/to/40-videos/") | ||
|
|
||
| print("Process many videos in parallel for dramatic speed improvements.") |
| print(" ❌ Errors: 0") | ||
| print("\nFor single video processing with verbose logs:") | ||
|
|
||
| verbose_pipeline = TranscriptPipeline(silent=False) # Default |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the unused local variable, either remove the assignment to verbose_pipeline if it's not needed or, if it's provided for illustrative/sample purposes, rename the variable to an accepted unused variable format (e.g., _ or unused_verbose_pipeline). In this context, since its only purpose is demonstrative and actual use is commented out, the clearest fix is to rename it to indicate it's deliberately unused: change verbose_pipeline to _, showing it's an intentionally ignored variable. This is a minimal change that preserves the example but eliminates the warning.
No additional imports or methods are needed; this is a straightforward renaming on line 151.
| @@ -148,7 +148,7 @@ | ||
| print(" ❌ Errors: 0") | ||
| print("\nFor single video processing with verbose logs:") | ||
|
|
||
| verbose_pipeline = TranscriptPipeline(silent=False) # Default | ||
| _ = TranscriptPipeline(silent=False) # Default | ||
| # result = verbose_pipeline.process("video.mp4") | ||
|
|
||
| print("For custom silent processing (useful for batch jobs):") |
|
|
||
| print("For custom silent processing (useful for batch jobs):") | ||
|
|
||
| silent_pipeline = TranscriptPipeline(silent=True) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this issue without changing existing functionality, we should rename the unused variable silent_pipeline on line 156 to something that explicitly indicates it is intentionally unused, such as unused_silent_pipeline. This follows the naming convention recommended in the background section and will silence linter/static analysis warnings while preserving the instructive nature of the example code. No additional imports, definitions, or method changes are required.
| @@ -153,8 +153,8 @@ | ||
|
|
||
| print("For custom silent processing (useful for batch jobs):") | ||
|
|
||
| silent_pipeline = TranscriptPipeline(silent=True) | ||
| # result = silent_pipeline.process("video.mp4") # No verbose logs | ||
| unused_silent_pipeline = TranscriptPipeline(silent=True) | ||
| # result = unused_silent_pipeline.process("video.mp4") # No verbose logs | ||
|
|
||
| print("Silent mode suppresses step-by-step logs while processing.\n") | ||
|
|
| from concurrent.futures import ProcessPoolExecutor, as_completed | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import List, Optional, Set |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this problem, we should remove the unused Set import from the import statement on line 7. We need to delete Set from from typing import List, Optional, Set in src/call2action/handover_pipeline.py, leaving only the used imports (List, Optional). This change is minimal and will not affect existing functionality.
| @@ -4,7 +4,7 @@ | ||
| from concurrent.futures import ProcessPoolExecutor, as_completed | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import List, Optional, Set | ||
| from typing import List, Optional | ||
|
|
||
| from call2action.config import Settings | ||
| from call2action.diagram_generator import DiagramGenerator |
| """Generate interactive HTML reports for project handover documentation.""" | ||
|
|
||
| import re | ||
| from datetime import datetime |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
The best way to fix the problem is to remove the unused import statement. Specifically, you should delete the line from datetime import datetime at line 4 in src/call2action/html_generator.py. No other changes, updates, or replacements are necessary, as no code references this import.
| @@ -1,7 +1,6 @@ | ||
| """Generate interactive HTML reports for project handover documentation.""" | ||
|
|
||
| import re | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import Dict, List | ||
|
|
| import re | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import Dict, List |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the problem, we should remove the unused import from line 6: specifically, delete List from from typing import Dict, List. This change should be made in the file src/call2action/html_generator.py. Only Dict is used, so the import statement should be revised to from typing import Dict. No other code changes or new imports are needed for this fix.
| @@ -3,7 +3,7 @@ | ||
| import re | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import Dict, List | ||
| from typing import Dict | ||
|
|
||
| from jinja2 import Template | ||
| from markupsafe import Markup |
| Rendered HTML string | ||
| """ | ||
| # Use Jinja2 to render the template | ||
| template = Template(self.template) |
Check warning
Code scanning / CodeQL
Jinja2 templating with autoescape=False Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this problem, we should ensure Jinja2 is configured to autoescape for HTML templates. The recommended way is to use the Jinja2 Environment class and initialize it with autoescape=select_autoescape(['html', 'xml']), using FileSystemLoader (or possibly BaseLoader for string templates). Since the report template is read from disk (not a file in a conventional templates directory), we can either:
- Load the template using
FileSystemLoader(if we know the template filename). - Use
EnvironmentwithBaseLoaderandfrom_string()for directly loaded template content.
The best fix, requiring minimal change, is to replace Template(self.template) with:
from jinja2 import Environment, select_autoescape, BaseLoader
env = Environment(
loader=BaseLoader(),
autoescape=select_autoescape(['html', 'xml'])
)
template = env.from_string(self.template)This ensures automatic escaping for HTML templates.
The checks and imports must be added.
Changes to make:
- Add missing imports (
Environment,select_autoescape,BaseLoader). - Replace the use of
Template(self.template)with an Environment-based template creation as above.
| @@ -5,7 +5,7 @@ | ||
| from pathlib import Path | ||
| from typing import Dict, List | ||
|
|
||
| from jinja2 import Template | ||
| from jinja2 import Template, Environment, select_autoescape, BaseLoader | ||
| from markupsafe import Markup | ||
|
|
||
| from call2action.models import HandoverReport | ||
| @@ -162,11 +162,14 @@ | ||
| Returns: | ||
| Rendered HTML string | ||
| """ | ||
| # Use Jinja2 to render the template | ||
| template = Template(self.template) | ||
| # Use Jinja2 Environment with autoescaping enabled for HTML/XML | ||
| env = Environment( | ||
| loader=BaseLoader(), | ||
| autoescape=select_autoescape(['html', 'xml']) | ||
| ) | ||
| template = env.from_string(self.template) | ||
| html = template.render(**variables) | ||
| return html | ||
|
|
||
| def _format_content(self, text: str) -> str: | ||
| """ | ||
| Convert markdown-like formatting to HTML. |
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import List, Optional | ||
| from typing import Dict, List, Optional, Tuple, Union |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the issue, remove the unused import of Union from the typing module in src/call2action/models.py. Specifically, edit line 6 so that only the used type annotations (Dict, List, Optional, and Tuple) are imported. No changes to functionality will occur by this removal, and all required imports for current usage will remain intact.
| @@ -3,7 +3,7 @@ | ||
| from dataclasses import dataclass, field | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import Dict, List, Optional, Tuple, Union | ||
| from typing import Dict, List, Optional, Tuple | ||
|
|
||
|
|
||
| @dataclass |
Add new feature:
Project Handover Documentation (New!)