-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Issue #506 #526
Issue #506 #526
Conversation
Pull Request Test Coverage Report for Build 1162
💛 - Coveralls |
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 main thing with this PR is that it introduces too many changes.
Please, fix your diffs and address my comments.
Thanks a lot for your hard-work! I really appreciate that. 🚀
|
||
incorrect_or_conditions1 = """ | ||
if some or ( | ||
other==1 |
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.
other == 1
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.
Complete
other, | ||
): | ||
... | ||
""" |
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.
Please, also include:
- Correct conditions with multiple
and
andor
- Correct conditions with
()
like function calls, prioritisation, and tuples - Incorrect conditions for multiple lines: 2, 3 and 4
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.
Complete
|
||
error_template = 'Found nested `try` block' | ||
code = 464 | ||
# -*- coding: utf-8 -*- |
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 diff is incorrect, please fix it.
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.
Fixed
tests/test_checker/test_noqa.py
Outdated
|
||
for violation in IGNORED_VIOLATIONS: | ||
assert stdout.count(violation) > 0 | ||
# -*- coding: utf-8 -*- |
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 diff is incorrect, please fix it.
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.
Fixed
tests/fixtures/noqa.py
Outdated
raise TypeError('Second') | ||
except TypeError: | ||
print('WTF?') | ||
# -*- coding: utf-8 -*- |
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 diff is incorrect, please fix it.
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.
fixed
Forbids to use magic numbers in your code. | ||
|
||
What we call a "magic number"? Well, it is actually any number that | ||
appears in your code ou |
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.
Also: use variables.
Forbids to use magic numbers in your code. | ||
|
||
What we call a "magic number"? Well, it is actually any number that | ||
appears in your code ou |
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.
0.9.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.
Complete
self._check_negated_conditions(node) | ||
self._check_redundant_else(node) | ||
self.generic_visit(node) | ||
# -*- coding: utf-8 -*- |
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 diff is incorrect, please fix it.
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.
fixed
|
||
def _check_multiline_conditions(self, node: ast.If) -> None: | ||
"""Checks multiline conditions ``if`` statement nodes.""" | ||
if isinstance(node.test, ast.BoolOp): |
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 you are ignoring cases like:
if very_long_call_name(
long_parameter_name=long_variable_name,
):
Please, make sure it is covered and tested.
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.
Change and tested it
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.
Complete. Please, review
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.
Almost ready, just two minor comments.
Awesome refactoring work. Thanks a lot!
@@ -378,3 +378,40 @@ def bad_default_values( # noqa: Z459 | |||
raise TypeError('Second') | |||
except TypeError: | |||
print('WTF?') | |||
|
|||
if some and ( # noqa: Z465 |
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.
There's no need in putting all of these cases inside noqa.py
.
It only contains integration tests. One is enough.
Move other cases into unit tests.
tests/test_checker/test_noqa.py
Outdated
@@ -151,6 +151,7 @@ def test_noqa_fixture_disabled(absolute_path, all_violations): | |||
'Z462': 1, | |||
'Z463': 1, | |||
'Z464': 1, | |||
'Z465': 5, |
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.
1
""" | ||
|
||
correct_conditions3 = """ | ||
if (some_func(k) and some) or other in (1,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.
Please, add:
correct_conditions4 = """
if one:
if two:
...
"""
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 did it.
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.
@shok9894 congrats! 🎉
Please, take other tasks if you want to.
Forbid multiline conditions, closes #506