-
Notifications
You must be signed in to change notification settings - Fork 159
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
chore: enable raise-without-from-inside-except ruff rule #1753
base: main
Are you sure you want to change the base?
Conversation
@@ -143,7 +143,7 @@ async def route_structure_fallback_middleware( | |||
structure_pointer = self.route_structure | |||
for component in components: | |||
if structure_pointer.get(component) is None: | |||
raise web.HTTPNotFound | |||
raise web.HTTPNotFound from None |
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.
In this case, I think we should simply reraise the original exception.
raise web.HTTPNotFound from None | |
raise |
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.
For the auto-generated as ex
expressions, I think it would be better to unify the style: as e
.
According to the official doc, Python automatically attach the chaining information when the raise
statement is inside an except
block.
We should force this rule only when the raise
statement is not inside the except
block.
@@ -350,9 +350,9 @@ async def _download_file( | |||
chunk_size | |||
) | |||
except asyncio.TimeoutError: | |||
raise TryAgain |
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.
Couldn't we just simply raise a "root" exception instead of specifying from None
always for brevity?
This will help investigating root cause of the error more easier when inspecting the error log.
Checklist: (if applicable)