-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruff: Add and fix RUF015 #11708
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
base: dev
Are you sure you want to change the base?
Ruff: Add and fix RUF015 #11708
Conversation
895b39b
to
f83b38d
Compare
DryRun Security SummaryA code review revealed multiple files were patched to improve code readability, with identified security concerns including minimal JSON data validation, potential information exposure, access control considerations, and a hardcoded API endpoint in specific files. Expand for full summarySummary: Multiple files were patched to replace list indexing with a new utility function Security Findings:
No other direct security vulnerabilities were identified across the reviewed files. |
Hey @kiblik I am super conflicted about this one, but have not landed on a stance I feel great about. On one hand, I like the approach of abstracting away I have no qualms with the ruff rule introduced here, but am on the fence about the use of the utility (we have a ton of those as it is 😅 ) |
I had also a bit of mixed feelings about this one as well. |
The main question is whether to introduce another util method and use it everywhere, right? We want to switch to using |
Yep, to util, or not util 😂 |
Gotcha, thanks. Yeah, tough one! I'll make some arguments for and against. For: I think Against: We could also split the difference: reports/widgets.py is the only place where this is used many times, so we could define and use the method there, and use FWIW I lean slightly toward not using the util method (at least as-is), but I won't shout into my pillow tonight if we decide to go with it. |
Let's do the |
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.
Approved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Originally proposed in #10712 but I didn't like Ruff's autofix
This PR is trying to address unnecessary-iterable-allocation-for-first-element (RUF015)
next(iter(x))
is proposed by Ruff but it is a bit hard to read it in code so I wrote a wrapper.Plus, I dropped som conversions to a
list
where it is not needed.