Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide a more friendly pointer on unconfigured constraint file #20781

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
29 changes: 20 additions & 9 deletions src/python/pants/backend/python/util_rules/pex_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,22 @@ def _common_failure_reasons(
failure_reasons: set[InvalidPythonLockfileReason], maybe_constraints_file_path: str | None
) -> Iterator[str]:
if InvalidPythonLockfileReason.CONSTRAINTS_FILE_MISMATCH in failure_reasons:
assert maybe_constraints_file_path is not None
yield softwrap(
f"""
- The constraints file at {maybe_constraints_file_path} has changed from when the
lockfile was generated. (Constraints files are set via the option
`[python].resolves_to_constraints_file`)
"""
)
if maybe_constraints_file_path is None:
yield softwrap(
"""
- Constraint file expected from lockfile metadata but no
constraints file configured. See the option
`[python].resolves_to_constraints_file`.
"""
)
else:
yield softwrap(
f"""
- The constraints file at {maybe_constraints_file_path} has changed from when the
lockfile was generated. (Constraints files are set via the option
`[python].resolves_to_constraints_file`)
"""
)
if InvalidPythonLockfileReason.ONLY_BINARY_MISMATCH in failure_reasons:
yield softwrap(
"""
Expand Down Expand Up @@ -652,7 +660,10 @@ def _invalid_lockfile_error(
yield f"\n\nSee {doc_url('docs/python/overview/interpreter-compatibility')} for details."

yield "\n\n"
yield from _common_failure_reasons(validation.failure_reasons, maybe_constraints_file_path)
yield from (
f"{fail}\n"
for fail in _common_failure_reasons(validation.failure_reasons, maybe_constraints_file_path)
)
yield "To regenerate your lockfile, "
yield f"run `{bin_name()} generate-lockfiles --resolve={resolve}`."
yield f"\n\nSee {doc_url('docs/python/overview/third-party-dependencies')} for details.\n\n"
Expand Down
Loading