Coverage for skema/program_analysis/comments.py: 0%
11 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
1from typing import List, Dict, Optional, Union
2from pydantic import BaseModel, Field
5class SingleLineComment(BaseModel):
6 contents: str
7 line_number: int
10class SingleFileCodeComments(BaseModel):
11 docstrings: Dict[str, List[str]] = Field(
12 description="A dictionary mapping a function name (str) to its associated docstring (List[str])",
13 examples=[{"fun1": ["Inputs: x,y", "Outputs: z"]}],
14 )
15 comments: List[SingleLineComment] = Field(
16 description="A list of comments, where each comment has a 'line_number' (int) and 'contents' (str) field",
17 examples=[{"contents": "Hello World!", "line_number": 0}],
18 )
21class MultiFileCodeComments(BaseModel):
22 files: Dict[str, SingleFileCodeComments] = Field(
23 description="Dictionary mapping file name (str) to extracted comments (SingleFileCodeComments)",
24 examples=[{
25 "file1.py": {
26 "comments": [{"contents": "Hello World!", "line_number": 0}],
27 "docstrings": {"fun1": ["Inputs: x,y", "Outputs: z"]},
28 }
29 }],
30 )
33CodeComments = Union[SingleFileCodeComments, MultiFileCodeComments]