Coverage for sel_tools/utils/comment.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-04 21:22 +0000

1"""Comment module.""" 

2 

3from dataclasses import dataclass, field 

4from pathlib import Path 

5 

6from sel_tools.file_parsing.slide_parser import get_attachments 

7 

8 

9@dataclass 

10class Comment: 

11 """Issue Comment.""" 

12 

13 issue_id: int 

14 message: str 

15 state_event: str | None = None 

16 attachments: list[Path] = field(default_factory=list) 

17 

18 @staticmethod 

19 def create(issue_id: int, message_or_file_path: str, state_event: str | None) -> "Comment": 

20 file_path = Path(message_or_file_path) 

21 message = file_path.read_text() if file_path.is_file() else message_or_file_path 

22 return Comment(issue_id, message, state_event, get_attachments(message))