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

Formatter is formatting inconsistent in CI #10302

Closed
joostlek opened this issue Mar 8, 2024 · 3 comments
Closed

Formatter is formatting inconsistent in CI #10302

joostlek opened this issue Mar 8, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@joostlek
Copy link

joostlek commented Mar 8, 2024

When upgrading to ruff 0.3.1 we encountered a special formatting issue in Ruff which was only happening in the CI.

When running ruff locally it seems to favor this variant:

    with patch(
        "bleak.BleakScanner.discovered_devices_and_advertisement_data",  # Must patch before we setup
        {
            "44:44:33:11:23:45": (
                MagicMock(address="44:44:33:11:23:45"),
                MagicMock(),
            )
        },
    ):

But when committing this and pushing this, the CI will complain that this is not correct:

diff --git a/tests/components/bluetooth/test_passive_update_coordinator.py b/tests/components/bluetooth/test_passive_update_coordinator.py
index cbe23142..f4128c98 100644
--- a/tests/components/bluetooth/test_passive_update_coordinator.py
+++ b/tests/components/bluetooth/test_passive_update_coordinator.py
@@ -142,14 +142,16 @@ async def test_unavailable_callbacks_mark_the_coordinator_unavailable(
 ) -> None:
     """Test that the coordinator goes unavailable when the bluetooth stack no longer sees the device."""
     start_monotonic = time.monotonic()
-    with patch(
-        "bleak.BleakScanner.discovered_devices_and_advertisement_data",  # Must patch before we setup
-        {
-            "44:44:33:11:23:45": (
-                MagicMock(address="44:44:33:11:23:45"),
-                MagicMock(),
-            )
-        },
+    with (
+        patch(
+            "bleak.BleakScanner.discovered_devices_and_advertisement_data",  # Must patch before we setup
+            {
+                "44:44:33:11:23:45": (
+                    MagicMock(address="44:44:33:11:23:45"),
+                    MagicMock(),
+                )
+            },
+        )
     ):

CI run
I mean that's strange, they usually are doing the same. But when we listen to the CI and commit what they propose we get this:

diff --git a/tests/components/bluetooth/test_passive_update_coordinator.py b/tests/components/bluetooth/test_passive_update_coordinator.py
index f4128c98..cbe23142 100644
--- a/tests/components/bluetooth/test_passive_update_coordinator.py
+++ b/tests/components/bluetooth/test_passive_update_coordinator.py
@@ -142,16 +142,14 @@ async def test_unavailable_callbacks_mark_the_coordinator_unavailable(
 ) -> None:
     """Test that the coordinator goes unavailable when the bluetooth stack no longer sees the device."""
     start_monotonic = time.monotonic()
-    with (
-        patch(
-            "bleak.BleakScanner.discovered_devices_and_advertisement_data",  # Must patch before we setup
-            {
-                "44:44:33:11:23:45": (
-                    MagicMock(address="44:44:33:11:23:45"),
-                    MagicMock(),
-                )
-            },
-        )
+    with patch(
+        "bleak.BleakScanner.discovered_devices_and_advertisement_data",  # Must patch before we setup
+        {
+            "44:44:33:11:23:45": (
+                MagicMock(address="44:44:33:11:23:45"),
+                MagicMock(),
+            )
+        },
     ):
         await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
         await hass.async_block_till_done()

CI run

Within the home assistant project we don't have any specific settings for the formatter (as far as I know).

Good to mention, both locally as in the CI pre-commit is used to run ruff.

Let me know if you need more information.

@charliermarsh
Copy link
Member

Thanks! There are a few open PRs from today to fix up issues in with formatting. I’m planning to review and merge them tonight (hopefully). I’ll check if they resolve this case.

@charliermarsh charliermarsh self-assigned this Mar 8, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Mar 8, 2024
@MichaReiser
Copy link
Member

Thanks for reporting, and I'm sorry for the inconvenience. I just tested the example in our playground that uses 0.3.2 and it now uses a consistent formatting. https://play.ruff.rs/99f78327-4a41-4c57-9b2c-bbfafab494a9

This is related to #10267

@joostlek
Copy link
Author

joostlek commented Mar 9, 2024

Ooh that also makes sense, i still run 3.11 locally and the CI just got updated to 3.12 yesterday afternoon. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants