Skip to content

Commit 605e70c

Browse files
author
MomIsBestFriend
committed
Fixes for review
1 parent 2b67601 commit 605e70c

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

Diff for: scripts/validate_string_concatenation.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ def main(source_path: str, output_format: str) -> bool:
5959

6060
is_failed: bool = False
6161

62+
msg = "String unnecessarily split in two by black. Please merge them manually."
63+
6264
if os.path.isfile(source_path):
6365
for source_path, line_number in strings_to_concatenate(source_path):
6466
is_failed = True
65-
msg = (
66-
"String unnecessarily split in two by black. "
67-
"Please merge them manually."
68-
)
6967
print(
7068
output_format.format(
7169
source_path=source_path, line_number=line_number, msg=msg
@@ -81,10 +79,6 @@ def main(source_path: str, output_format: str) -> bool:
8179
os.path.join(subdir, file_name)
8280
):
8381
is_failed = True
84-
msg = (
85-
"String unnecessarily split in two by black. "
86-
"Please merge them manually."
87-
)
8882
print(
8983
output_format.format(
9084
source_path=source_path, line_number=line_number, msg=msg
@@ -104,19 +98,17 @@ def strings_to_concatenate(source_path: str) -> Generator[Tuple[str, int], None,
10498
10599
Yields
106100
------
107-
Tuple
108-
Containing:
109-
source_path
110-
Source file path.
111-
line_number
112-
Line number of unconcatenated string.
101+
source_path : str
102+
Source file path.
103+
line_number : int
104+
Line number of unconcatenated string.
113105
"""
114106
with open(source_path, "r") as file_name:
115107
tokens: List = list(tokenize.generate_tokens(file_name.readline))
116108

117109
for current_token, next_token in zip(tokens, tokens[1:]):
118110
if current_token[0] == next_token[0] == token.STRING:
119-
yield (source_path, current_token[2][0])
111+
yield source_path, current_token[2][0]
120112

121113

122114
if __name__ == "__main__":

0 commit comments

Comments
 (0)