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
Fix part of issue #8423 Lint concatenation checker #19908
base: develop
Are you sure you want to change the base?
Conversation
Hi @Helper2020, can you complete the following:
|
Assigning @vojtechjelinek for the first pass review of this PR. Thanks! |
Unassigning @Helper2020 since a re-review was requested. @Helper2020, please make sure you have addressed all review comments. Thanks! |
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.
Thanks @Helper2020! Could you please fix the lint checks that are failing on CI? Thanks.
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.
Thanks! Left a few comments.
scripts/linters/pylint_extensions.py
Outdated
if (isinstance(left_inferred.value, str) and | ||
isinstance(right_inferred.value, str)): | ||
self.add_message('prefer-string-interpolation', node=node) |
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.
if (isinstance(left_inferred.value, str) and | |
isinstance(right_inferred.value, str)): | |
self.add_message('prefer-string-interpolation', node=node) | |
if ( | |
isinstance(left_inferred.value, str) and | |
isinstance(right_inferred.value, str) | |
): | |
self.add_message('prefer-string-interpolation', node=node) |
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.
Done.
Unassigning @vojtechjelinek since the review is done. |
@Helper2020 please correct the issues flagged by Oppiabot in #19908 (comment):
I'm de-assigning myself for now until these issues and CI checks are fixed |
@vojtechjelinek I'm not sure how I can handle errors from .infer() without try-except blocks. Any suggestions? |
Why can't you use try-except? |
I can, just according to the coding style guide, raising exceptions are rarely used. |
@Helper2020 How long more do you need? |
|
@Helper2020 Okay I tried re-running the failed jobs. |
@StephenYu2018 PTAL, @vojtechjelinek PTAL, @seanlip PTAL |
Unassigning @Helper2020 since a re-review was requested. @Helper2020, please make sure you have addressed all review comments. Thanks! |
@StephenYu2018 PTAL, @vojtechjelinek PTAL, @seanlip PTAL |
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 have no new changes to request. Please address my remaining reviewer comments, as I've left some new comments under those threads. Once that's done, I'll approve these changes.
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.
Thanks @Helper2020. Looks great! I just left a few notes on my codeowner files, PTAL.
score_category: str = ('%s%s%s' % ( | ||
suggestion_models.SCORE_TYPE_TRANSLATION, | ||
suggestion_models.SCORE_CATEGORY_DELIMITER, 'English') | ||
) |
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.
Deindent by 4 (to match opening scope).
suggestion_models.SCORE_TYPE_TRANSLATION + | ||
suggestion_models.SCORE_CATEGORY_DELIMITER + 'English') | ||
'%s%s%s' % ( | ||
suggestion_models.SCORE_TYPE_TRANSLATION, |
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.
Indent this line and the next by 4 from the previous line, since the ( introduces a new indentation scope.
@@ -410,7 +410,7 @@ def _get_trimmed_error_output(html_lint_output: str) -> str: | |||
|
|||
for line in html_output_lines: | |||
trimmed_error_messages.append(line) | |||
return '\n'.join(trimmed_error_messages) + '\n' | |||
return '\n%s%s' % (''.join(trimmed_error_messages), '\n') |
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.
Why not just put the last \n in the main string literal?
@@ -526,7 +526,7 @@ def _get_trimmed_error_output(eslint_output: str) -> str: | |||
else: | |||
error_message = line | |||
trimmed_error_messages.append(error_message) | |||
return '\n'.join(trimmed_error_messages) + '\n' | |||
return '\n%s%s' % (trimmed_error_messages, '\n') |
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.
Ditto, put the last \n in the main string literal
@@ -2919,6 +2919,55 @@ def visit_importfrom(self, node: astroid.nodes.ImportFrom) -> None: | |||
self.add_message('disallowed-text-import', node=node) | |||
|
|||
|
|||
# TODO(#16567): Here we use MyPy ignore because of the incomplete typing of |
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.
Strike the first "of"
# (Class cannot subclass 'BaseChecker' (has type 'Any')), | ||
# we added an ignore here. | ||
class PreventStringConcatenationChecker(checkers.BaseChecker): # type: ignore[misc] | ||
"""Checks for string concactenation and encourage string interpolation.""" |
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.
encourage --> encourages
Args: node: astroid.BinOp The binary operation node to check. | ||
""" | ||
|
||
if isinstance(node, astroid.BinOp) and node.op == '+': |
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.
Not done? (I don't see the changes in the code.)
'-linux-x64.tar.gz', | ||
'https://nodejs.org/dist/v%s/node-v%s%s' % ( | ||
common.NODE_VERSION, common.NODE_VERSION, | ||
'-linux-x64.tar.gz'), |
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.
Why not just add this to the main string, since it is hardcoded?
Overview
Essential Checklist