-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
document new codemod str concat in seq literals
- Loading branch information
1 parent
1964726
commit bc11c8e
Showing
6 changed files
with
68 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from core_codemods.str_concat_in_seq_literal import StrConcatInSeqLiteral | ||
from integration_tests.base_test import ( | ||
BaseIntegrationTest, | ||
original_and_expected_from_code_path, | ||
) | ||
|
||
|
||
class TestStrConcatInSeqLiteral(BaseIntegrationTest): | ||
codemod = StrConcatInSeqLiteral | ||
code_path = "tests/samples/str_concat_in_sequence_literals.py" | ||
original_code, expected_new_code = original_and_expected_from_code_path( | ||
code_path, | ||
[ | ||
(1, """ "ab",\n"""), | ||
(4, """ "gh",\n"""), | ||
], | ||
) | ||
|
||
# fmt: off | ||
expected_diff =( | ||
"""--- \n""" | ||
"""+++ \n""" | ||
"""@@ -1,7 +1,7 @@\n""" | ||
""" bad = [\n""" | ||
"""- "ab"\n""" | ||
"""+ "ab",\n""" | ||
""" "cd",\n""" | ||
""" "ef",\n""" | ||
"""- "gh"\n""" | ||
"""+ "gh",\n""" | ||
""" "ij",\n""" | ||
""" ]\n""") | ||
# fmt: on | ||
|
||
expected_line_change = "1" | ||
change_description = StrConcatInSeqLiteral.change_description | ||
num_changes = 2 |
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
14 changes: 14 additions & 0 deletions
14
src/core_codemods/docs/pixee_python_str-concat-in-sequence-literals.md
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,14 @@ | ||
This codemod fixes cases of implicit string concatenation inside lists, sets, or tuples. This is most likely a mistake: you probably meant include a comma in between the concatenated strings. | ||
|
||
Our changes look something like this: | ||
```diff | ||
bad = [ | ||
- "ab" | ||
+ "ab", | ||
"cd", | ||
"ef", | ||
- "gh" | ||
+ "gh", | ||
"ij", | ||
] | ||
``` |
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,7 @@ | ||
bad = [ | ||
"ab" | ||
"cd", | ||
"ef", | ||
"gh" | ||
"ij", | ||
] |