mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Associate a trailing end-of-line comment in a parenthesized implicit concatenated string with the last literal (#15378)
This commit is contained in:
parent
adca7bd95c
commit
2b28d566a4
6 changed files with 378 additions and 8 deletions
|
@ -291,3 +291,87 @@ aaaaa[aaaaaaaaaaa] = (
|
|||
f"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||
=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
||||
)
|
||||
|
||||
|
||||
# Trailing last-part comments
|
||||
|
||||
a = (
|
||||
"a"
|
||||
"b" # belongs to `b`
|
||||
)
|
||||
|
||||
a: Literal[str] = (
|
||||
"a"
|
||||
"b" # belongs to `b`
|
||||
)
|
||||
|
||||
a += (
|
||||
"a"
|
||||
"b" # belongs to `b`
|
||||
)
|
||||
|
||||
a = (
|
||||
r"a"
|
||||
r"b" # belongs to `b`
|
||||
)
|
||||
|
||||
a = (
|
||||
"a"
|
||||
"b"
|
||||
) # belongs to the assignment
|
||||
|
||||
a = (((
|
||||
"a"
|
||||
"b" # belongs to `b`
|
||||
)))
|
||||
|
||||
a = (((
|
||||
"a"
|
||||
"b"
|
||||
) # belongs to the f-string expression
|
||||
))
|
||||
|
||||
a = (
|
||||
"a" "b" # belongs to the f-string expression
|
||||
)
|
||||
|
||||
a = (
|
||||
"a" "b"
|
||||
# belongs to the f-string expression
|
||||
)
|
||||
|
||||
# There's no "right" answer if some parts are on the same line while others are on separate lines.
|
||||
# This is likely a comment for one of the last two parts but could also just be a comment for the entire f-string expression.
|
||||
# Because there's no right answer, follow what we do elsewhere and associate the comment with the outer-most node which
|
||||
# is the f-string expression.
|
||||
a = (
|
||||
"a"
|
||||
"b" "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" # belongs to the f-string expression
|
||||
)
|
||||
|
||||
logger.error(
|
||||
f"Failed to run task {task} for job"
|
||||
f"with id {str(job.id)}" # type: ignore[union-attr]
|
||||
)
|
||||
|
||||
a = (10 +
|
||||
"Exception in {call_back_name} "
|
||||
f"'{msg}'" # belongs to binary operation
|
||||
)
|
||||
|
||||
a = 10 + (
|
||||
"Exception in {call_back_name} "
|
||||
f"'{msg}'" # belongs to f-string
|
||||
)
|
||||
|
||||
self._attr_unique_id = (
|
||||
f"{self._device.temperature.group_address_state}_"
|
||||
f"{self._device.target_temperature.group_address_state}_"
|
||||
f"{self._device.target_temperature.group_address}_"
|
||||
f"{self._device._setpoint_shift.group_address}" # noqa: SLF001
|
||||
)
|
||||
|
||||
return (
|
||||
f"Exception in {call_back_name} when handling msg on "
|
||||
f"'{msg.topic}': '{msg.payload}'" # type: ignore[str-bytes-safe]
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue