-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[trailing-comma-tuple] Fix enabling with message control locally when disabled for the file #9609
[trailing-comma-tuple] Fix enabling with message control locally when disabled for the file #9609
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9609 +/- ##
=======================================
Coverage 95.84% 95.84%
=======================================
Files 174 174
Lines 18897 18904 +7
=======================================
+ Hits 18112 18119 +7
Misses 785 785
|
7b56a61
to
6e45258
Compare
This comment has been minimized.
This comment has been minimized.
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.
Just saw your comment on the issue. This does indeed not work.
Jeez, I wonder why ruff don't have fine grained message control yet 😄 (I did not benchmark this yet, I probably need to test some assumptions about the caching of per line enable vs checking the enable on each token). |
This comment has been minimized.
This comment has been minimized.
d1ad751
to
5cd7c05
Compare
5cd7c05
to
42eff43
Compare
This comment has been minimized.
This comment has been minimized.
Wow, |
This comment has been minimized.
This comment has been minimized.
Hmm, do we know if this actually meaningfully influences performance? Yes calling a function often is bad, but if the effect on performance is negligible than we might not want to overcomplicate our config handling (again). |
I was thinking about misleadingness rather than performance. {Number of files} calls is not that problematic, but the function name making me lose 2 hours of debug is :D |
By the way I still don't understand why locally everything work and not in the CI, but I'm short on time atm. |
Does this fix #8201? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c088a47
to
2ea3405
Compare
Thanks for your work here on this important improvement. I'm wondering what you think about backporting performance improvements. Should we try to keep the patch releases more stable by only backporting bugfixes and not refactors? |
Oh woah, I had it backwards. This is the bugfix. Carry on! |
2ea3405
to
daeab1f
Compare
I can understand the confusion because I'm trying very hard to optimize the bug fix itself 😄 |
daeab1f
to
865d57c
Compare
4dd9da9
to
1eedcbb
Compare
disable=trailing-comma-tuple | ||
|
||
[testoptions] | ||
exclude_from_minimal_messages_config=True |
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.
Got very confused by that error at first (Didn't see it was a specific automated test that was failing). I chose the fast fix but maybe taking into account the conf file after disabling everything and checking what's expected in the functional test would be better than the current behavior.
Was a review on #9620, this MR was repurposed.
# Process tokens and look for 'if' or 'elif' | ||
for index, token in enumerate(tokens): | ||
token_string = token[1] | ||
if ( |
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.
What do you think about factoring this out into a helper method? It's almost 20 lines with comments.
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 do think we need to make this kind of optimization where we do not compute things when a message is disabled easier to use because the faster computation is the one you never do.
If we create an helper then we'd probably want to parametrize "trailing-comma-tuple" / "R1707" so it can be useful elsewhere with other messages (then we should be using the message store to get old name of the message if a message was ever renamed ?). And it adds a call.
We have the "perfect function" for this already with self.linter.is_message_enabled(
applied on a line (barring some optimization to do here related to not launching it on each token as they are multiple token per line). It felt very heavy handed in this case so I did something very specific without check for old name / and without exact check of enabling or not.
To be honest I made a lot of assumptions without ever doing a benchmark. One way to keep this clean and dry would be to make the message store better for this use case (token checks, and probably enabled but not absolutely sure it still is?).
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.
No worries, we can merge as is. I wasn't suggesting reusing it elsewhere, I just meant hoisting it out of this current location into a few lines up in the same file.
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 1eedcbb |
… disabled for the file (#9609) (#9649) * [trailing-comma-tuple] Set the confidence to HIGH * [trailing-comma-tuple] Properly emit when disabled globally and enabled locally * [trailing-comma-tuple] Handle case with space between 'enable' and '=' (cherry picked from commit 96fad05) Co-authored-by: Pierre Sassoulas <[email protected]>
Type of Changes
Description
Refs #8606, #9620 (follow-up)
Closes #9608