Skip to content

Commit 868bfd0

Browse files
committed
fix: normalize manifest keys to POSIX, type manifest parameter
- Store manifest file keys using as_posix() after resolving relative to project root, ensuring cross-platform portable manifests - Type the manifest parameter as IntegrationManifest (via TYPE_CHECKING import) instead of Any in IntegrationBase methods
1 parent 0695542 commit 868bfd0

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/specify_cli/integrations/base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
from abc import ABC
1414
from dataclasses import dataclass
1515
from pathlib import Path
16-
from typing import Any
16+
from typing import TYPE_CHECKING, Any
17+
18+
if TYPE_CHECKING:
19+
from .manifest import IntegrationManifest
1720

1821

1922
# ---------------------------------------------------------------------------
@@ -95,7 +98,7 @@ def templates_dir(self) -> Path:
9598
def setup(
9699
self,
97100
project_root: Path,
98-
manifest: Any,
101+
manifest: IntegrationManifest,
99102
parsed_options: dict[str, Any] | None = None,
100103
**opts: Any,
101104
) -> list[Path]:
@@ -143,7 +146,7 @@ def setup(
143146
def teardown(
144147
self,
145148
project_root: Path,
146-
manifest: Any,
149+
manifest: IntegrationManifest,
147150
*,
148151
force: bool = False,
149152
) -> tuple[list[Path], list[Path]]:
@@ -161,7 +164,7 @@ def teardown(
161164
def install(
162165
self,
163166
project_root: Path,
164-
manifest: Any,
167+
manifest: IntegrationManifest,
165168
parsed_options: dict[str, Any] | None = None,
166169
**opts: Any,
167170
) -> list[Path]:
@@ -173,7 +176,7 @@ def install(
173176
def uninstall(
174177
self,
175178
project_root: Path,
176-
manifest: Any,
179+
manifest: IntegrationManifest,
177180
*,
178181
force: bool = False,
179182
) -> tuple[list[Path], list[Path]]:

src/specify_cli/integrations/manifest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def record_file(self, rel_path: str | Path, content: bytes | str) -> Path:
8787
content = content.encode("utf-8")
8888
abs_path.write_bytes(content)
8989

90-
self._files[str(rel)] = hashlib.sha256(content).hexdigest()
90+
normalized = abs_path.relative_to(self.project_root).as_posix()
91+
self._files[normalized] = hashlib.sha256(content).hexdigest()
9192
return abs_path
9293

9394
def record_existing(self, rel_path: str | Path) -> None:
@@ -97,7 +98,8 @@ def record_existing(self, rel_path: str | Path) -> None:
9798
"""
9899
rel = Path(rel_path)
99100
abs_path = _validate_rel_path(rel, self.project_root)
100-
self._files[str(rel)] = _sha256(abs_path)
101+
normalized = abs_path.relative_to(self.project_root).as_posix()
102+
self._files[normalized] = _sha256(abs_path)
101103

102104
# -- Querying ---------------------------------------------------------
103105

0 commit comments

Comments
 (0)