FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(project): report malformed lockfiles with DependencyError · pythonnative/pythonnative@2b571d1 · GitHub

Repository navigation

Commit 2b571d1

Browse files
committed
fix(project): report malformed lockfiles with DependencyError
Closes #90
1 parent 481a592 commit 2b571d1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/pythonnative/project/lockfile.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ def read(config: AppConfig) -> dict[str, Any] | None:
6464
path = config.project_root / NAME
6565
if not path.exists():
6666
return None
67-
value = json.loads(path.read_text(encoding="utf-8"))
67+
try:
68+
value = json.loads(path.read_text(encoding="utf-8"))
69+
except json.JSONDecodeError as exc:
70+
raise DependencyError(
71+
f"{NAME} is not valid JSON. Run 'pn deps --lock' to regenerate it."
72+
) from exc
73+
if not isinstance(value, dict):
74+
raise DependencyError(
75+
f"{NAME} must be a JSON object. Run 'pn deps --lock' to regenerate it."
76+
)
6877
if (
6978
value.get("version") != 1
7079
or value.get("python") != config.python_version

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL