WPS345: forbid symmetric bitwise operations (#3593)#3598
Open
j2cry wants to merge 2 commits intowemake-services:masterfrom
Open
WPS345: forbid symmetric bitwise operations (#3593)#3598j2cry wants to merge 2 commits intowemake-services:masterfrom
j2cry wants to merge 2 commits intowemake-services:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3598 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 368 368
Lines 12255 12291 +36
Branches 846 853 +7
=========================================
+ Hits 12255 12291 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@sobolevn can you review it, please? |
sobolevn
reviewed
Feb 17, 2026
| '-~8 ^ -~8', | ||
| '+7 & +++7', | ||
| '-~-7 | -~-7', | ||
| '(not not --7) ^ 7', |
Member
There was a problem hiding this comment.
Can you please test -7 ^ 7? Should it raise?
Contributor
Author
There was a problem hiding this comment.
It won't raise, because this expression is asymmetric.
In general, an expression n ^ -n, as well as for & and | operators, requires calculation, i.e.
7 ^ -7 == -2
80 | -80 == -16
52 & -52 == 4
I think this can be used in some very specific logic. While n ^ n is always 0, and n & n, n | n is always n.
| - Fixes false positive `WPS457` for ``while True`` loop with ``await`` expressions, #3753 | ||
| - Fixes the false positive `WPS617` by assigning a function that receives a lambda expression as a parameter. | ||
| - Fixes false positive `WPS430` for whitelisted nested functions, #3589 | ||
| - Fixes `WPS345` to forbid symmetric bitwise operations, #3593 |
Member
There was a problem hiding this comment.
This is not a fix, it is a new feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have made things!
This forbids symmetric bitwise operations of constants.
Checklist
CHANGELOG.mdRelated issues
Refs #3593