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

Raise InvalidRequirement/Marker from exc #593

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion packaging/markers.py
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ def __init__(self, marker: str) -> None:
raise InvalidMarker(
f"Invalid marker: {marker!r}, parse error at "
f"{marker[e.position : e.position + 8]!r}"
)
) from e

def __str__(self) -> str:
return _format_marker(self._markers)
2 changes: 1 addition & 1 deletion packaging/requirements.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ def __init__(self, requirement_string: str) -> None:
try:
req = parse_named_requirement(requirement_string)
except ParseExceptionError as e:
raise InvalidRequirement(str(e))
raise InvalidRequirement(str(e)) from e
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if repeating the string from e gets us anything. I think raising the appropriate exception is important for except clauses, but a person looking at the output can look at the traceback to see what ultimately triggered the exception.

Suggested change
raise InvalidRequirement(str(e)) from e
raise InvalidRequirement from e


self.name: str = req.name
if req.url: