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

fix: brief only when __str__ for errors #929

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 1 addition & 9 deletions craft_parts/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,7 @@ def __init__(
self.doc_slug = doc_slug

def __str__(self) -> str:
components = [self.brief]

if self.details:
components.append(self.details)

if self.resolution:
components.append(self.resolution)

return "\n".join(components)
return self.brief
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand how this error is ending up in craft-cli?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I linked to it


def __repr__(self) -> str:
return f"{self.__class__.__name__}(brief={self.brief!r}, details={self.details!r}, resolution={self.resolution!r}, doc_slug={self.doc_slug!r})"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_parts_error_brief():

def test_parts_error_full():
err = errors.PartsError(brief="Brief", details="Details", resolution="Resolution")
assert str(err) == "Brief\nDetails\nResolution"
assert str(err) == "Brief"
assert (
repr(err)
== "PartsError(brief='Brief', details='Details', resolution='Resolution', doc_slug=None)"
Expand Down
Loading