Skip to content

Commit

Permalink
- made inclusion of "import" statements optional;
Browse files Browse the repository at this point in the history
  • Loading branch information
jaltmayerpizzorno committed Aug 29, 2024
1 parent 0f55b4f commit 1d6b359
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/coverup/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def initial_prompt(self, segment: CodeSegment) -> T.List[dict]:
calling into pytest.main or the test itself.
Respond ONLY with the Python code enclosed in backticks, without any explanation.
```python
{segment.get_excerpt(tag_lines=False)}
{segment.get_excerpt(tag_lines=False, include_imports=False)}
```
""")
]
Expand Down
7 changes: 4 additions & 3 deletions src/coverup/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def identify(self) -> str:
def __str__(self) -> str:
return self.identify()

def get_excerpt(self, tag_lines=True):
def get_excerpt(self, tag_lines=True, include_imports=True):
excerpt = []
with open(self.filename, "r") as src:
code = src.readlines()

for imp in self.imports:
excerpt.extend([f"{'':10} {imp}\n"])
if include_imports:
for imp in self.imports:
excerpt.extend([f"{'':10} {imp}\n"])

for b, e in self.context:
for i in range(b, e):
Expand Down

0 comments on commit 1d6b359

Please sign in to comment.