Skip to content

Commit 2deed7b

Browse files
committed
fix(plugins): fix chezmoi file locking, curl runner type, and conftest mypy error
1 parent 2bdfe60 commit 2deed7b

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

plugins/chezmoi/src/plugin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ def write_yaml(file_path: str, data: dict) -> None:
4242
os.makedirs(os.path.dirname(file_path), exist_ok=True)
4343

4444
fd, temp_path = tempfile.mkstemp(dir=os.path.dirname(file_path), prefix="chezmoi.yaml.")
45+
os.close(fd)
4546
try:
4647
import yaml
4748

48-
with os.fdopen(fd, "w", encoding="utf-8") as f:
49+
with open(temp_path, "w", encoding="utf-8") as f:
4950
yaml.safe_dump(data, f, default_flow_style=False, sort_keys=False)
5051
os.replace(temp_path, file_path)
5152
except Exception:
52-
os.unlink(temp_path)
53+
if os.path.exists(temp_path):
54+
try:
55+
os.unlink(temp_path)
56+
except Exception:
57+
pass
5358
raise
5459

5560

plugins/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
sys.modules["winreg"] = MagicMock()
1111
mock_winapi = MagicMock()
1212
del mock_winapi.CopyFile2
13-
shutil._winapi = mock_winapi
13+
setattr(shutil, "_winapi", mock_winapi)
1414

1515

1616
# Remove any dynamically inserted plugin source/test directories from sys.path

plugins/curl/plugin.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ name: curl
22
description: Manage curl HTTP client settings
33
author: VIDYANKSHINI
44
version: 1.0.0
5-
type: config_provider
6-
entrypoint: python src/plugin.py
5+
type: python
6+
main: src/plugin.py
7+
capabilities:
8+
- config_provider

0 commit comments

Comments
 (0)