Skip to content

Commit

Permalink
Remove required keys check and minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisarpit committed Sep 2, 2024
1 parent 30d0965 commit 0a31d37
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions patchwork/steps/GetTypescriptTypeInfo/GetTypescriptTypeInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,16 @@
class GetTypescriptTypeInfo(Step, input_class=GetTypescriptTypeInfoInputs, output_class=GetTypescriptTypeInfoOutputs):
def __init__(self, inputs: dict):
super().__init__(inputs)
required_keys = {"file_path", "variable_name"}
if not all(key in inputs.keys() for key in required_keys):
raise ValueError(f'Missing required data: "{required_keys}"')

self.inputs = inputs
self.file_path = inputs.get("file_path")
self.variable_name = inputs.get("variable_name")

def run(self) -> dict:
file_path = self.inputs["file_path"]
variable_name = self.inputs["variable_name"]

cwd = Path.cwd()

full_file_path = os.path.join(cwd, file_path)

# Get the directory of the current script
# current_dir = cwd

# Construct the path to get_type_info.ts
# get_type_info_path = os.path.join(current_dir, "get_type_info.ts")

# Run the subprocess call
subprocess.run(["tsx", _DEFAULT_TS_FILE, full_file_path, variable_name], check=True, cwd=cwd)
full_file_path = os.path.join(cwd, self.file_path)

# Read the output file
subprocess.run(["tsx", _DEFAULT_TS_FILE, full_file_path, self.variable_name], check=True, cwd=cwd)
output_path = os.path.join(cwd, "temp_output_declaration.txt")
with open(output_path, "r") as f:
type_info = f.read()
Expand Down

0 comments on commit 0a31d37

Please sign in to comment.