machineconfig 6.73__py3-none-any.whl → 6.74__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.

Potentially problematic release.


This version of machineconfig might be problematic. Click here for more details.

@@ -4,7 +4,7 @@ from collections.abc import Callable
4
4
  from typing import Any
5
5
 
6
6
 
7
- def get_import_module_string(py_file: str):
7
+ def get_import_module_string(py_file: str) -> str:
8
8
  from machineconfig.scripts.python.helpers_fire.helpers4 import get_import_module_code
9
9
  from machineconfig.utils.accessories import get_repo_root
10
10
  from pathlib import Path
@@ -111,7 +111,7 @@ def lambda_to_python_script(lmb: Callable[[], Any], in_global: bool, import_modu
111
111
  import_prefix = get_import_module_string(str(_Path(module_path_candidate)))
112
112
 
113
113
  # Evaluate each keyword argument value in the lambda's globals to get real Python objects
114
- call_kwargs = {}
114
+ call_kwargs: dict[str, Any] = {}
115
115
  for kw in body.keywords:
116
116
  if kw.arg is None:
117
117
  # **kwargs in call — evaluate to dict and merge
@@ -135,7 +135,6 @@ def lambda_to_python_script(lmb: Callable[[], Any], in_global: bool, import_modu
135
135
  orig_src = _inspect.getsource(func_obj)
136
136
  ded = _textwrap.dedent(orig_src)
137
137
  lines = ded.splitlines()
138
- # find the line that starts with def <name>(
139
138
  def_index = None
140
139
  for i, ln in enumerate(lines):
141
140
  if ln.lstrip().startswith(f"def {func_name}("):
@@ -144,19 +143,30 @@ def lambda_to_python_script(lmb: Callable[[], Any], in_global: bool, import_modu
144
143
  if def_index is None:
145
144
  body_lines = ded.splitlines()
146
145
  else:
147
- body_lines = lines[def_index + 1 :]
146
+ signature_end_index = None
147
+ for i in range(def_index, len(lines)):
148
+ line_no_comment = lines[i].split("#", 1)[0].rstrip()
149
+ if line_no_comment.endswith(":"):
150
+ signature_end_index = i
151
+ break
152
+ if signature_end_index is None:
153
+ body_lines = lines[def_index + 1 :]
154
+ else:
155
+ body_lines = lines[signature_end_index + 1 :]
148
156
  # ensure we have a body, otherwise use pass
149
157
  if not any(line.strip() for line in body_lines):
150
158
  body_text = " pass\n"
151
159
  else:
152
- # keep the dedented body lines exactly as-is (they should be indented)
153
- body_text = "\n".join(body_lines) + ("\n" if not body_lines[-1].endswith("\n") else "")
160
+ joined_body = "\n".join(body_lines)
161
+ if not joined_body.endswith("\n"):
162
+ joined_body = f"{joined_body}\n"
163
+ body_text = joined_body
154
164
  except (OSError, IOError, TypeError):
155
165
  body_text = " pass\n"
156
166
 
157
167
  # Build a replaced signature using inspect.signature
158
168
  sig = _inspect.signature(func_obj)
159
- new_params = []
169
+ new_params: list[_inspect.Parameter] = []
160
170
  for name, param in sig.parameters.items():
161
171
  # If the call provided a value for this parameter, replace default
162
172
  if name in call_kwargs:
@@ -217,7 +227,7 @@ def lambda_to_python_script(lmb: Callable[[], Any], in_global: bool, import_modu
217
227
 
218
228
  if import_prefix:
219
229
  return f"{import_prefix}{result_text}"
220
- return result_text
230
+ return f"""from typing import Optional, Any, Literal""" + "\n" + result_text
221
231
 
222
232
 
223
233
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machineconfig
3
- Version: 6.73
3
+ Version: 6.74
4
4
  Summary: Dotfiles management package
5
5
  Author-email: Alex Al-Saffar <programmer@usa.com>
6
6
  License: Apache 2.0
@@ -400,7 +400,7 @@ machineconfig/utils/code.py,sha256=FGM3s422q0I4zoYi2Gftohj1xZpyL7XKAHM__oEVGZg,5
400
400
  machineconfig/utils/installer.py,sha256=UzI_DtTcKbgvkAkWkNLAPUtx-RVqITHCpvZyLiCpD9g,10377
401
401
  machineconfig/utils/io.py,sha256=4dSieoqZO8Vvi4vW8lLoITDHBvmFp4dtl3kyeZHQ6Co,2528
402
402
  machineconfig/utils/links.py,sha256=KM6vIn3hag9FYEzLSHP5MAM9tU_RStw2mCq2_OvmmZA,23672
403
- machineconfig/utils/meta.py,sha256=wVa4C6wV7pqrpwmQ6IEaPxK3Xew9NxM6HpDMu51q5kI,9053
403
+ machineconfig/utils/meta.py,sha256=af7q6p9ASpc_YXL564ptGgo7ZgmlmX4Av11si8O27bY,9511
404
404
  machineconfig/utils/notifications.py,sha256=tuXIudcip0tEioG-bm8BbLr3FMDve4f6BktlznBhKxM,9013
405
405
  machineconfig/utils/options.py,sha256=vUO4Kej-vDOv64wHr2HNDyu6PATURpjd7xp6N8OOoJg,7083
406
406
  machineconfig/utils/path_extended.py,sha256=WyJwoHnXdvSQQJ-yrxTX78FpqYmgVeKDYpNEB9UsRck,53223
@@ -438,8 +438,8 @@ machineconfig/utils/schemas/installer/installer_types.py,sha256=QClRY61QaduBPJoS
438
438
  machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
439
439
  machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
440
440
  machineconfig/utils/ssh_utils/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
441
- machineconfig-6.73.dist-info/METADATA,sha256=oj87PggeTxlHlJ60TZGV5AOBLteOPqeDWiefj8yoAOc,2928
442
- machineconfig-6.73.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
443
- machineconfig-6.73.dist-info/entry_points.txt,sha256=NTW7hbUlpt5Vx9DdQrONLkYMCuBXpvYh1dt0AtlGxeI,466
444
- machineconfig-6.73.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
445
- machineconfig-6.73.dist-info/RECORD,,
441
+ machineconfig-6.74.dist-info/METADATA,sha256=692qBPW0k0wBu8OAbluLRsNWPapPYstbPzf7eLIVXkw,2928
442
+ machineconfig-6.74.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
443
+ machineconfig-6.74.dist-info/entry_points.txt,sha256=NTW7hbUlpt5Vx9DdQrONLkYMCuBXpvYh1dt0AtlGxeI,466
444
+ machineconfig-6.74.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
445
+ machineconfig-6.74.dist-info/RECORD,,