-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Added rule to enfore stricter slicing operations and unit tests for it. #1069
Conversation
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.
Awesome! Almost done!
We have to also update tests/fixtures/noqa.py
and tests/test_checker/test_noqa.py
to enable an integration test.
CHANGELOG.md
Outdated
@@ -82,6 +82,7 @@ It features a lot of new rules from different categories. | |||
- Forbids to use and declare `float` keys in arrays and dictionaries | |||
- Forbids to use `a[len(a) - 1]` because it is just `a[-1]` | |||
- Forbids too long call chains like `foo(a)(b)(c)(d)` | |||
- Enforces stricter slice operation usage |
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.
This should go to 0.15.0
section
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.
Could you be more specific? I don't see a section 0.15.0
in CHANGELOG.md
. It only goes up to 0.13.3
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.
That's what you have to create 🙂
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.
Okay! Could you explain reasoning why this is going into a new section rather than 0.13.0?
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.
Because 0.13
is already released, and we are working on 0.15
'3::2', | ||
'5:7:', | ||
':7:2', | ||
'3::', |
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.
Looks like this subscript also does not make any sense. Why would anyone want to write 3::
and not just 3:
?
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.
Related #1071
'5:7:', | ||
':7:2', | ||
'3::', | ||
':7:', |
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.
The same here. Why not just :7
?
# Wrong: | ||
items[::-1] | ||
|
||
.. versionadded:: 0.13.0 |
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.
.. versionadded:: 0.15.0
""" | ||
|
||
error_template = 'Found undescriptive slice operation' | ||
code = 500 |
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.
Code is not correct. This violation should be located in refactoring.py
and have a correct code.
@@ -23,9 +23,10 @@ def visit_Subscript(self, node: ast.Subscript) -> None: | |||
|
|||
Raises: | |||
RedundantSubscriptViolation | |||
|
|||
UndescriptiveSliceOperationViolation |
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.
Missing new line after this
In |
@sobolevn Just wanted to bump this in case you didn't see my last question. |
@Eric4Jiang oh, sorry. I have missed it. The range for refactoring is |
I am closing this for now, feel free to reopen if you still want to work on this. Cheers! 👍 |
I have made things!
Checklist
CHANGELOG.md
Related issues