-
Notifications
You must be signed in to change notification settings - Fork 241
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
Conversation
I think I would rather see the change be |
Do you have an opinion, @pradyunsg ? |
I don’t have any opinion either way, |
I mostly made this PR because I found this traceback excessively big considering both exceptions convey the same amount of information. Still, I guess it would make more sense to use |
Then please use the |
@@ -39,7 +39,7 @@ def __init__(self, requirement_string: str) -> None: | |||
try: | |||
req = _RequirementTuple(*parse_named_requirement(requirement_string)) | |||
except ParseExceptionError as e: | |||
raise InvalidRequirement(str(e)) | |||
raise InvalidRequirement(str(e)) from e |
There was a problem hiding this comment.
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.
raise InvalidRequirement(str(e)) from e | |
raise InvalidRequirement from e |
This PR uses
raise from exc
syntax to improve the traceback from:to: