forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally disable consider-using-join for non-empty separator (pylin…
…t-dev#9129) * Skip consider-using-join for non-empty separators Only suggest joining with separators when a new option 'suggest-join-with-non-empty-separator' is specified. Co-authored-by: Pierre Sassoulas <[email protected]>
- Loading branch information
1 parent
3afa971
commit 0796dfa
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Skip ``consider-using-join`` check for non-empty separators if an ``suggest-join-with-non-empty-separator`` option is set to ``no``. | ||
|
||
Closes #8701 |
This file contains 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
24 changes: 24 additions & 0 deletions
24
tests/functional/c/consider/consider_join_for_non_empty_separator.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# pylint: disable=missing-docstring,invalid-name,undefined-variable,multiple-statements | ||
|
||
result = 'a' | ||
for number in ['1', '2', '3']: | ||
result += f'b{number}' | ||
assert result == 'ab1b2b3' | ||
assert result == 'b'.join(['a', '1', '2', '3']) | ||
|
||
result = 'a' | ||
for number in ['1', '2', '3']: | ||
result += f'{number}c' | ||
assert result == 'a1c2c3c' | ||
assert result == 'a' + 'c'.join(['1', '2', '3']) + 'c' | ||
|
||
result = 'a' | ||
for number in ['1', '2', '3']: | ||
result += f'b{number}c' | ||
assert result == 'ab1cb2cb3c' | ||
assert result == 'ab' + 'cb'.join(['1', '2', '3']) + 'c' | ||
|
||
result = '' | ||
for number in ['1', '2', '3']: | ||
result += f"{number}, " | ||
result = result[:-2] |
2 changes: 2 additions & 0 deletions
2
tests/functional/c/consider/consider_join_for_non_empty_separator.rc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[variables] | ||
suggest-join-with-non-empty-separator=no |