Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit concatenated f-string: Trailing end-of-line comment is moved #15375

Open
joostlek opened this issue Jan 9, 2025 · 4 comments · May be fixed by #15378
Open

Implicit concatenated f-string: Trailing end-of-line comment is moved #15375

joostlek opened this issue Jan 9, 2025 · 4 comments · May be fixed by #15378
Assignees
Labels
bug Something isn't working formatter Related to the formatter

Comments

@joostlek
Copy link

joostlek commented Jan 9, 2025

Hey!

So I just started bumping ruff in Home Assistant core to 0.9.0 to match the 2025 python guidelines and I encountered a bug.

https://github.com/home-assistant/core/blob/a10d5c435a4b48c9c2549db28f966f2c08ba3a96/homeassistant/components/knx/climate.py#L212-L217

ruff moved the noqa: SLF001 to the next line, but the next run it starts to complain about that we access a private member.

2024:

        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
        )

2025:

        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
homeassistant/components/knx/climate.py:216:16: SLF001 Private member accessed: `_setpoint_shift`
    |
214 |             f"{self._device.target_temperature.group_address_state}_"
215 |             f"{self._device.target_temperature.group_address}_"
216 |             f"{self._device._setpoint_shift.group_address}"
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001
217 |         )  # noqa: SLF001
218 |         self.default_hvac_mode: HVACMode = config[
    |

Found 1 error.
@joostlek
Copy link
Author

joostlek commented Jan 9, 2025

Found another one

2024

        return (
            f"Exception in {call_back_name} when handling msg on "
            f"'{msg.topic}': '{msg.payload}'"  # type: ignore[str-bytes-safe]
        )

2025

        return (
            f"Exception in {call_back_name} when handling msg on "
            f"'{msg.topic}': '{msg.payload}'"
        )  # type: ignore[str-bytes-safe]

@MichaReiser MichaReiser added bug Something isn't working formatter Related to the formatter labels Jan 9, 2025
@MichaReiser
Copy link
Member

Wow, you're quick with upgrading. I haven't been able to finish the release just yet :) Yes, this looks like a bug

@joostlek
Copy link
Author

joostlek commented Jan 9, 2025

It looked breaking and exciting so I couldn't hold myself ;)

@MichaReiser MichaReiser self-assigned this Jan 9, 2025
@MichaReiser
Copy link
Member

Okay, I think I know how to fix this one. Thanks for reporting

@MichaReiser MichaReiser changed the title noqa gets moved to the new line Implicit concatenated f-string: Trailing end-of-line comment is moved Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter Related to the formatter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants