ripple-down-rules 0.6.1__py3-none-any.whl → 0.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,20 +109,21 @@ class TemplateFileCreator:
109
109
 
110
110
  self.open_file_in_editor()
111
111
 
112
- def open_file_in_editor(self):
112
+ def open_file_in_editor(self, file_path: Optional[str] = None):
113
113
  """
114
114
  Open the file in the available editor.
115
115
  """
116
+ file_path = file_path or self.temp_file_path
116
117
  if self.editor_cmd is not None:
117
- subprocess.Popen([self.editor_cmd, self.temp_file_path],
118
+ subprocess.Popen([self.editor_cmd, file_path],
118
119
  stdout=subprocess.DEVNULL,
119
120
  stderr=subprocess.DEVNULL)
120
121
  elif self.editor == Editor.Pycharm:
121
- subprocess.Popen(["pycharm", "--line", str(self.user_edit_line), self.temp_file_path],
122
+ subprocess.Popen(["pycharm", "--line", str(self.user_edit_line), file_path],
122
123
  stdout=subprocess.DEVNULL,
123
124
  stderr=subprocess.DEVNULL)
124
125
  elif self.editor == Editor.Code:
125
- subprocess.Popen(["code", self.temp_file_path])
126
+ subprocess.Popen(["code", file_path])
126
127
  elif self.editor == Editor.CodeServer:
127
128
  try:
128
129
  subprocess.check_output(["pgrep", "-f", "code-server"])
@@ -134,7 +135,8 @@ class TemplateFileCreator:
134
135
  except (subprocess.CalledProcessError, ValueError) as e:
135
136
  self.process = start_code_server(self.workspace)
136
137
  self.print_func(f"Open code-server in your browser at http://localhost:{self.port}?folder={self.workspace}")
137
- self.print_func(f"Edit the file: {Fore.MAGENTA}{self.temp_file_path}")
138
+ if file_path.endswith('.py'):
139
+ self.print_func(f"Edit the file: {Fore.MAGENTA}{file_path}")
138
140
 
139
141
  def build_boilerplate_code(self):
140
142
  imports = self.get_imports()
@@ -175,6 +177,8 @@ class TemplateFileCreator:
175
177
  if self.case_query.is_function:
176
178
  func_args = {}
177
179
  for k, v in self.case_query.case.items():
180
+ if k == self.case_query.attribute_name:
181
+ continue
178
182
  if (self.case_query.function_args_type_hints is not None
179
183
  and k in self.case_query.function_args_type_hints):
180
184
  func_args[k] = stringify_hint(self.case_query.function_args_type_hints[k])
@@ -182,8 +186,9 @@ class TemplateFileCreator:
182
186
  func_args[k] = type(v).__name__ if not isinstance(v, type) else f"Type[{v.__name__}]"
183
187
  func_args = ', '.join([f"{k}: {v}" if str(v) not in ["NoneType", "None"] else str(k)
184
188
  for k, v in func_args.items()])
189
+ func_args += ", **kwargs"
185
190
  else:
186
- func_args = f"case: {self.case_type.__name__}"
191
+ func_args = f"case: {self.case_query.case_type.__name__}"
187
192
  return func_args
188
193
 
189
194
  def write_to_file(self, code: str):
@@ -212,7 +217,7 @@ class TemplateFileCreator:
212
217
  else:
213
218
  case_type_imports.append(v)
214
219
  else:
215
- case_type_imports.append(self.case_type)
220
+ case_type_imports.append(self.case_query.case_type)
216
221
  if self.output_type is None:
217
222
  output_type_imports = [Any]
218
223
  else:
@@ -302,7 +307,7 @@ class TemplateFileCreator:
302
307
  exec(source, scope, exec_globals)
303
308
  user_function = exec_globals[func_name]
304
309
  updates[func_name] = user_function
305
- print_func(f"{Fore.BLUE}Loaded `{func_name}` function into user namespace.{Style.RESET_ALL}")
310
+ print_func(f"\n{Fore.WHITE}Loaded the following function into user namespace:\n{Fore.GREEN}{func_name}{Style.RESET_ALL}")
306
311
  break
307
312
  if updates:
308
313
  all_code_lines = extract_function_source(file_path,