We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1f779de commit 0cf39efCopy full SHA for 0cf39ef
1 file changed
src/black/strings.py
@@ -96,13 +96,13 @@ def get_string_prefix(string: str) -> str:
96
"""
97
assert_is_leaf_string(string)
98
99
- prefix = ""
100
- prefix_idx = 0
101
- while string[prefix_idx] in STRING_PREFIX_CHARS:
102
- prefix += string[prefix_idx]
103
- prefix_idx += 1
104
-
105
- return prefix
+ prefix = []
+ for char in string:
+ if char in STRING_PREFIX_CHARS:
+ prefix.append(char)
+ else:
+ break
+ return "".join(prefix)
106
107
108
def assert_is_leaf_string(string: str) -> None:
0 commit comments