Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion hatch_pip_compile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ def _get_supported_environments(cls) -> set[str]:
capture_output=True,
check=True,
)
environment_dict: dict[str, Any] = json.loads(result.stdout)
# Extract the relevant JSON output by extracting the last line in stdout,
# to prevent JSONDecodeError.
# When present, previous lines might be logs from Hatch plugins,
# like custom environment collectors.
envs_raw = result.stdout.strip().rsplit(b"\n", maxsplit=1)[-1]
environment_dict: dict[str, Any] = json.loads(envs_raw)
return {
key for key, value in environment_dict.items() if value.get("type") == "pip-compile"
}
Expand Down