Commit Graph

17 Commits

Author SHA1 Message Date
Bryan Bugyi
e2fd914dc1
Fix internal error when FORCE_OPTIONAL_PARENTHESES feature is enabled (#2332)
Fixes #2313.
2021-06-13 10:20:50 -07:00
jack1142
62402a3261
Support named escapes (\N{...}) in string processing (#2319)
Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-06-09 12:29:32 -07:00
Richard Si
00e7e12a3a
Regression fix: leave R prefixes capitalization alone (#2285)
`black.strings.get_string_prefix` used to lowercase the extracted
prefix before returning it. This is wrong because 1) it ignores the
fact we should leave R prefixes alone because of MagicPython, and 2)
there is dedicated prefix casing handling code that fixes issue 1.
`.lower` is too naive.

This was originally fixed in 20.8b0, but was reintroduced since 21.4b0.

I also added proper prefix normalization for docstrings by using the
`black.strings.normalize_string_prefix` helper.

Some more test strings were added to make sure strings with capitalized
prefixes aren't treated differently (actually happened with my original
patch, Jelle had to point it out to me).
2021-06-08 17:46:09 -07:00
Bryan Bugyi
99b68e59ce
Fix incorrect custom breakpoint indices when string group contains fake f-strings (#2311)
Fixes #2293
2021-06-07 07:03:39 -07:00
Bryan Bugyi
6380b9f2f6
Account for += assignment when deciding whether to split string (#2312)
Fixes #2294
2021-06-07 07:01:57 -07:00
Bryan Bugyi
199e3eb76b
Fix regular expression that black uses to identify f-expressions (#2287)
Fixes #1469
2021-05-30 15:34:33 -07:00
Bryan Bugyi
4ca4407b4a
Make sure to split lines that start with a string operator (#2286)
Fixes #2284
2021-05-30 23:41:03 +02:00
Bryan Bugyi
eec44f5977
Fix --experiemental-string-processing crash when matching parens not found (#2283)
Fixes #2271
2021-05-30 12:32:28 -07:00
Bryan Bugyi
e912c7ff54
Fix INTERNAL ERROR caused by removing parens from pointless string (#1888)
Fixes #1846.
2020-12-28 12:30:23 -08:00
Bryan Bugyi
edf1c9dc0f
Fix bug which causes f-expressions to be split (#1809)
Closes #1807.
2020-11-06 16:17:23 -08:00
Bryan Bugyi
6c3f818185
Fix bug where black tries to split string on escaped space (#1799)
Closes #1505.
2020-10-31 10:42:36 -07:00
Bryan Bugyi
cd055efd7d
Fix unstable subscript assignment string wrapping (#1678)
Fixes #1598
2020-09-10 09:24:01 -07:00
Bryan Bugyi
6284953d07
Fix crash on assert and parenthesized % format (fixes #1597, fixes #1605) (#1681) 2020-09-06 09:15:40 -07:00
Bryan Bugyi
7bca930ca3
Fix crash on concatenated string + comment (fixes #1596) (#1677)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2020-09-06 08:02:57 -07:00
Bryan Bugyi
e3ccabb23c
Fix unstable formatting on string split + % formatting (#1680)
Fixes #1595
2020-09-05 17:24:00 -07:00
Łukasz Langa
788268bc39 Re-implement magic trailing comma handling:
- when a trailing comma is specified in any bracket pair, that signals to Black
  that this bracket pair needs to be always exploded, e.g. presented as "one
  item per line";

- this causes some changes to previously formatted code that erroneously left
  trailing commas embedded into single-line expressions;

- internally, Black needs to be able to identify trailing commas that it put
  itself compared to pre-existing trailing commas. We do this by using/abusing
  lib2to3's `was_checked` attribute.  It's True for internally generated
  trailing commas and False for pre-existing ones (in fact, for all
  pre-existing leaves and nodes).

Fixes #1288
2020-08-21 16:45:30 +02:00
Bryan Bugyi
544ea9c217
Improve String Handling (#1132)
This pull request's main intention is to wraps long strings (as requested by #182); however, it also provides better string handling in general and, in doing so, closes the following issues:

Closes #26
Closes #182
Closes #933
Closes #1183
Closes #1243
2020-05-08 14:56:21 +02:00