From fb46579d30bdb5c1c3eb8f6beaf553d50594df8b Mon Sep 17 00:00:00 2001 From: konsti Date: Fri, 14 Jul 2023 11:55:05 +0200 Subject: [PATCH] Add Regression test for #5605, where formatting `x[:,]` failed. (#5759) #5605 has been fixed, i added the failing example from the issue as a regression test. Closes #5605 --- .../resources/test/fixtures/ruff/expression/slice.py | 3 +++ .../tests/snapshots/format@expression__slice.py.snap | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py index 7406108226..8e0b32b72e 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py @@ -80,3 +80,6 @@ e200 = "e"[a() :: ] e201 = "e"[a() :: 1] e202 = "e"[a() :: a()] e210 = "e"[a() : 1 :] + +# Regression test for https://github.com/astral-sh/ruff/issues/5605 +f = "f"[:,] diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap index 1ea479d8c8..5c9251a69d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__slice.py.snap @@ -86,6 +86,9 @@ e200 = "e"[a() :: ] e201 = "e"[a() :: 1] e202 = "e"[a() :: a()] e210 = "e"[a() : 1 :] + +# Regression test for https://github.com/astral-sh/ruff/issues/5605 +f = "f"[:,] ``` ## Output @@ -170,6 +173,9 @@ e200 = "e"[a() : :] e201 = "e"[a() :: 1] e202 = "e"[a() :: a()] e210 = "e"[a() : 1 :] + +# Regression test for https://github.com/astral-sh/ruff/issues/5605 +f = "f"[:,] ```