Skip to content

Commit a9a94b1

Browse files
committed
save
1 parent 8b81f19 commit a9a94b1

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

patchwork/steps/ReadFile/ReadFile.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from patchwork.common.utils.utils import open_with_chardet
2+
from patchwork.step import Step
3+
from patchwork.steps.ReadFile.typed import ReadFileInputs
4+
5+
6+
class ReadFile(Step):
7+
def __init__(self, inputs):
8+
super().__init__(inputs)
9+
missing_keys = ReadFileInputs.__required_keys__.difference(inputs.keys())
10+
if len(missing_keys) > 0:
11+
raise ValueError(f"Missing required data: {missing_keys}")
12+
13+
self.file = inputs["file_path"]
14+
15+
def run(self):
16+
with open_with_chardet("r", self.file) as f:
17+
file_contents = f.read()
18+
19+
return dict(file_content=file_contents)

patchwork/steps/ReadFile/__init__.py

Whitespace-only changes.

patchwork/steps/ReadFile/typed.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing_extensions import TypedDict
2+
3+
4+
class ReadFileInputs(TypedDict):
5+
file_path: str
6+
7+
8+
class ReadFileOutputs(TypedDict):
9+
file_content: str

patchwork/steps/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"CallAPI",
4444
"CallCode2Prompt",
4545
"CallLLM",
46-
"Combine"
46+
"Combine",
4747
"CommitChanges",
4848
"CreateIssue",
4949
"CreateIssueComment",
@@ -63,6 +63,7 @@
6363
"PreparePR",
6464
"PreparePrompt",
6565
"QueryEmbeddings",
66+
"ReadFile",
6667
"ReadIssues",
6768
"ReadPRDiffs",
6869
"ScanDepscan",

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "patchwork-cli"
3-
version = "0.0.44.dev1"
3+
version = "0.0.44.dev2"
44
description = ""
55
authors = ["patched.codes"]
66
license = "AGPL"

0 commit comments

Comments
 (0)