- Added `--required-version` option to require a specific version to be running (#2300)
- Fix incorrect custom breakpoint indices when string group contains fake f-strings
(#2311)
+- Fix regression where `R` prefixes would be lowercased for docstrings (#2285)
## 21.5b2
if is_docstring(leaf) and "\\\n" not in leaf.value:
# We're ignoring docstrings with backslash newline escapes because changing
# indentation of those changes the AST representation of the code.
- prefix = get_string_prefix(leaf.value)
- docstring = leaf.value[len(prefix) :] # Remove the prefix
+ docstring = normalize_string_prefix(leaf.value, self.remove_u_prefix)
+ prefix = get_string_prefix(docstring)
+ docstring = docstring[len(prefix) :] # Remove the prefix
quote_char = docstring[0]
# A natural way to remove the outer quotes is to do:
# docstring = docstring.strip(quote_char)
prefix = ""
prefix_idx = 0
while string[prefix_idx] in STRING_PREFIX_CHARS:
- prefix += string[prefix_idx].lower()
+ prefix += string[prefix_idx]
prefix_idx += 1
return prefix
and is_valid_index(next_str_idx)
and LL[next_str_idx].type == token.STRING
):
- prefix = get_string_prefix(LL[next_str_idx].value)
+ prefix = get_string_prefix(LL[next_str_idx].value).lower()
next_str_idx += 1
# The next loop merges the string group. The final string will be
num_of_strings += 1
SS = LL[next_str_idx].value
- next_prefix = get_string_prefix(SS)
+ next_prefix = get_string_prefix(SS).lower()
# If this is an f-string group but this substring is not prefixed
# with 'f'...
return TErr("StringMerger does NOT merge multiline strings.")
num_of_strings += 1
- prefix = get_string_prefix(leaf.value)
+ prefix = get_string_prefix(leaf.value).lower()
if "r" in prefix:
return TErr("StringMerger does NOT merge raw strings.")
is_valid_index = is_valid_index_factory(LL)
insert_str_child = insert_str_child_factory(LL[string_idx])
- prefix = get_string_prefix(LL[string_idx].value)
+ prefix = get_string_prefix(LL[string_idx].value).lower()
# We MAY choose to drop the 'f' prefix from substrings that don't
# contain any f-expressions, but ONLY if the original f-string
yield from _fexpr_slices
- is_fstring = "f" in get_string_prefix(string)
+ is_fstring = "f" in get_string_prefix(string).lower()
def breaks_fstring_expression(i: Index) -> bool:
"""
f"9. You now have a key to add to `{prefix}set api youtube api_key`"
)
+# It shouldn't matter if the string prefixes are capitalized.
+temp_msg = (
+ F"{F'{humanize_number(pos)}.': <{pound_len+2}} "
+ F"{balance: <{bal_len + 5}} "
+ F"<<{author.display_name}>>\n"
+)
+
+fstring = (
+ F"We have to remember to escape {braces}."
+ " Like {these}."
+ F" But not {this}."
+)
+
+welcome_to_programming = R"hello," R" world!"
+
+fstring = F"f-strings definitely make things more {difficult} than they need to be for {{black}}. But boy they sure are handy. The problem is that some lines will need to have the 'f' whereas others do not. This {line}, for example, needs one."
+
+x = F"This is a long string which contains an f-expr that should not split {{{[i for i in range(5)]}}}."
+
+
# output
"8. No application restrictions are needed. Click Create at the bottom."
f"9. You now have a key to add to `{prefix}set api youtube api_key`"
)
+
+# It shouldn't matter if the string prefixes are capitalized.
+temp_msg = (
+ f"{F'{humanize_number(pos)}.': <{pound_len+2}} "
+ f"{balance: <{bal_len + 5}} "
+ f"<<{author.display_name}>>\n"
+)
+
+fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
+
+welcome_to_programming = R"hello," R" world!"
+
+fstring = (
+ f"f-strings definitely make things more {difficult} than they need to be for"
+ " {black}. But boy they sure are handy. The problem is that some lines will need"
+ f" to have the 'f' whereas others do not. This {line}, for example, needs one."
+)
+
+x = (
+ "This is a long string which contains an f-expr that should not split"
+ f" {{{[i for i in range(5)]}}}."
+)
r"hello"
fR"hello"
+
+def docstring_singleline():
+ R"""2020 was one hell of a year. The good news is that we were able to"""
+
+
+def docstring_multiline():
+ R"""
+ clear out all of the issues opened in that time :p
+ """
+
+
# output
b"hello"
r"hello"
fR"hello"
+
+
+def docstring_singleline():
+ R"""2020 was one hell of a year. The good news is that we were able to"""
+
+
+def docstring_multiline():
+ R"""
+ clear out all of the issues opened in that time :p
+ """