refactor: use pathlib for file paths in new export handlers
CONTRIBUTING.md mandates pathlib.Path over os.path (added for cross-platform/Linux support); the rest of the codebase's newer code already follows it. Converts the 19 new _handle_export_* handlers to pathlib (exists/mkdir/iterdir/is_file, expanduser().resolve()) so this feature's new code is compliant. Tests updated to patch pathlib.Path. Scope is limited to the new export-handler block; the pre-existing os.path usage elsewhere in kicad_interface.py/export.py is untouched here and will be migrated in a dedicated refactor PR to keep that sweep reviewable in isolation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,10 +64,10 @@ def _call(iface, suffix, params, rc=0, stderr=""):
|
||||
fake = SimpleNamespace(returncode=rc, stdout="", stderr=stderr)
|
||||
with (
|
||||
patch("subprocess.run", return_value=fake) as run,
|
||||
patch("os.path.exists", return_value=True),
|
||||
patch("os.makedirs"),
|
||||
patch("os.listdir", return_value=["a.out"]),
|
||||
patch("os.path.isfile", return_value=True),
|
||||
patch("pathlib.Path.exists", return_value=True),
|
||||
patch("pathlib.Path.mkdir"),
|
||||
patch("pathlib.Path.iterdir", return_value=[]),
|
||||
patch("pathlib.Path.is_file", return_value=True),
|
||||
):
|
||||
result = method(dict(params))
|
||||
return result, run
|
||||
|
||||
Reference in New Issue
Block a user