Fix unstable subscript assignment string wrapping (#1678)

Fixes #1598
This commit is contained in:
Bryan Bugyi 2020-09-10 12:24:01 -04:00 committed by GitHub
parent 1e8916f450
commit cd055efd7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -3507,9 +3507,12 @@ def __get_max_string_length(self, line: Line, string_idx: int) -> int:
# WMA4 a single space.
offset += 1
# WMA4 the lengths of any leaves that came before that space.
for leaf in LL[: p_idx + 1]:
# WMA4 the lengths of any leaves that came before that space,
# but after any closing bracket before that space.
for leaf in reversed(LL[: p_idx + 1]):
offset += len(str(leaf))
if leaf.type in CLOSING_BRACKETS:
break
if is_valid_index(string_idx + 1):
N = LL[string_idx + 1]

View File

@ -349,6 +349,10 @@ def xxxxxxx_xxxxxx(xxxx):
x.xxxxx.xxxxxx.xxxxx.xxxx,
], ("xxxxxxxxxxx xxxxxxx xxxx (xxxxxx xxxx) %x xxx xxxxx" % xxxxxxx_xxxx)
value.__dict__[
key
] = "test" # set some Thrift field to non-None in the struct aa bb cc dd ee
# output
@ -784,3 +788,8 @@ def xxxxxxx_xxxxxx(xxxx):
], (
"xxxxxxxxxxx xxxxxxx xxxx (xxxxxx xxxx) %x xxx xxxxx" % xxxxxxx_xxxx
)
value.__dict__[
key
] = "test" # set some Thrift field to non-None in the struct aa bb cc dd ee