mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 07:38:00 +00:00
Split implicit concatenated strings before binary expressions (#7145)
This commit is contained in:
parent
9671922e40
commit
e376c3ff7e
20 changed files with 1067 additions and 366 deletions
|
@ -319,6 +319,21 @@ expected_content = (
|
|||
self.base_url
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
rowuses = [(1 << j) | # column ordinal
|
||||
(1 << (n + i-j + n-1)) | # NW-SE ordinal
|
||||
(1 << (n + 2*n-1 + i+j)) # NE-SW ordinal
|
||||
for j in rangen]
|
||||
|
||||
skip_bytes = (
|
||||
header.timecnt * 5 # Transition times and types
|
||||
+ header.typecnt * 6 # Local time type records
|
||||
+ header.charcnt # Time zone designations
|
||||
+ header.leapcnt * 8 # Leap second records
|
||||
+ header.isstdcnt # Standard/wall indicators
|
||||
+ header.isutcnt # UT/local indicators
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -697,6 +712,25 @@ expected_content = (
|
|||
self.base_url
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
rowuses = [
|
||||
(
|
||||
1 << j # column ordinal
|
||||
)
|
||||
| (1 << (n + i - j + n - 1)) # NW-SE ordinal
|
||||
| (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal
|
||||
for j in rangen
|
||||
]
|
||||
|
||||
skip_bytes = (
|
||||
header.timecnt * 5 # Transition times and types
|
||||
+ header.typecnt * 6 # Local time type records
|
||||
+ header.charcnt # Time zone designations
|
||||
+ header.leapcnt * 8 # Leap second records
|
||||
+ header.isstdcnt # Standard/wall indicators
|
||||
+ header.isutcnt # UT/local indicators
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -124,6 +124,48 @@ def test3():
|
|||
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
|
||||
"THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)"
|
||||
) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3
|
||||
|
||||
c = (a +
|
||||
# test leading binary comment
|
||||
"a" "b" * b
|
||||
)
|
||||
|
||||
c = (a *
|
||||
# test leading comment
|
||||
"a" "b" + b
|
||||
)
|
||||
|
||||
c = (a
|
||||
+ # test trailing comment
|
||||
"a" "b" * b
|
||||
)
|
||||
|
||||
c = (a
|
||||
+
|
||||
"a" "b" # test trailing comment
|
||||
* b
|
||||
)
|
||||
|
||||
c = (a
|
||||
*
|
||||
"a" "b" # test trailing binary comment
|
||||
+ b
|
||||
)
|
||||
|
||||
c = (a
|
||||
*
|
||||
"a" "b"
|
||||
+ # test trailing operator comment
|
||||
b
|
||||
)
|
||||
|
||||
c = (a
|
||||
*
|
||||
"a" "b"
|
||||
+
|
||||
# test trailing operator comment
|
||||
b
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -215,18 +257,13 @@ self._assert_skipping(
|
|||
(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
"cccccccccccccccccccccccccc" % aaaaaaaaaaaa
|
||||
+ x
|
||||
"cccccccccccccccccccccccccc" % aaaaaaaaaaaa + x
|
||||
)
|
||||
|
||||
(
|
||||
b
|
||||
+ c
|
||||
+ d
|
||||
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
b + c + d + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
"cccccccccccccccccccccccccc" % aaaaaaaaaaaa
|
||||
+ x
|
||||
"cccccccccccccccccccccccccc" % aaaaaaaaaaaa + x
|
||||
)
|
||||
|
||||
(
|
||||
|
@ -243,8 +280,7 @@ self._assert_skipping(
|
|||
self.assertEqual(
|
||||
response.status_code,
|
||||
status_code,
|
||||
msg_prefix
|
||||
+ "Couldn't retrieve content: Response code was %d"
|
||||
msg_prefix + "Couldn't retrieve content: Response code was %d"
|
||||
" (expected %d)" % (response.status_code, status_code),
|
||||
)
|
||||
|
||||
|
@ -268,6 +304,54 @@ def test3():
|
|||
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
|
||||
"THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)"
|
||||
) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3
|
||||
|
||||
|
||||
c = (
|
||||
a +
|
||||
# test leading binary comment
|
||||
"a"
|
||||
"b" * b
|
||||
)
|
||||
|
||||
c = (
|
||||
a *
|
||||
# test leading comment
|
||||
"a"
|
||||
"b" + b
|
||||
)
|
||||
|
||||
c = (
|
||||
a
|
||||
+ # test trailing comment
|
||||
"a"
|
||||
"b" * b
|
||||
)
|
||||
|
||||
c = (
|
||||
a + "a"
|
||||
"b" # test trailing comment
|
||||
* b
|
||||
)
|
||||
|
||||
c = (
|
||||
a * "a"
|
||||
"b" # test trailing binary comment
|
||||
+ b
|
||||
)
|
||||
|
||||
c = (
|
||||
a * "a"
|
||||
"b"
|
||||
+ # test trailing operator comment
|
||||
b
|
||||
)
|
||||
|
||||
c = (
|
||||
a * "a"
|
||||
"b" +
|
||||
# test trailing operator comment
|
||||
b
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -222,8 +222,7 @@ b"Let's" b"start" b"with" b"a" b"simple" b"example" b"now repeat after me:" b"I
|
|||
)
|
||||
|
||||
if (
|
||||
a
|
||||
+ b"Let's"
|
||||
a + b"Let's"
|
||||
b"start"
|
||||
b"with"
|
||||
b"a"
|
||||
|
@ -371,8 +370,7 @@ b"Let's" b'start' b'with' b'a' b'simple' b'example' b'now repeat after me:' b'I
|
|||
)
|
||||
|
||||
if (
|
||||
a
|
||||
+ b"Let's"
|
||||
a + b"Let's"
|
||||
b'start'
|
||||
b'with'
|
||||
b'a'
|
||||
|
|
|
@ -240,8 +240,7 @@ String \"\"\"
|
|||
)
|
||||
|
||||
if (
|
||||
a
|
||||
+ "Let's"
|
||||
a + "Let's"
|
||||
"start"
|
||||
"with"
|
||||
"a"
|
||||
|
@ -410,8 +409,7 @@ String \"\"\"
|
|||
)
|
||||
|
||||
if (
|
||||
a
|
||||
+ "Let's"
|
||||
a + "Let's"
|
||||
'start'
|
||||
'with'
|
||||
'a'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue