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

Fix regressions for black #2339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix regressions for black #2339

wants to merge 1 commit into from

Conversation

staticdev
Copy link
Collaborator

Closes #2338

@staticdev staticdev requested a review from DanielNoord January 17, 2025 17:06
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.12%. Comparing base (4ae58fa) to head (380d7a2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2339   +/-   ##
=======================================
  Coverage   99.12%   99.12%           
=======================================
  Files          40       40           
  Lines        3096     3096           
  Branches      787      787           
=======================================
  Hits         3069     3069           
  Misses         15       15           
  Partials       12       12           

@matthewhughes934
Copy link
Contributor

The change from #2236 looks to not play nice when using with imports, here's a patch that adds a test that will fail when parsing the output:

diff --git a/tests/unit/profiles/test_black.py b/tests/unit/profiles/test_black.py
index 8f750100..027ebce4 100644
--- a/tests/unit/profiles/test_black.py
+++ b/tests/unit/profiles/test_black.py
@@ -456,3 +456,15 @@ def test_black_trailing_comma():
 )
 """,
     )
+
+def test_black_trailing_comma2():
+    black_test(
+        """\
+from x import ( a as b,)
+""",
+        """\
+from x import (
+    a as b,
+)
+""",
+    )

@matthewhughes934
Copy link
Contributor

matthewhughes934 commented Jan 17, 2025

maybe there's an existing bug with split_on_trailing_comma, here's a test that reproduces the issue on 6550a74 (picking a random commit that was from a few months ago)

diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index ddfa4e24..9d237128 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -5559,11 +5559,9 @@ def seekable(self):
 
 
 def test_split_on_trailing_comma() -> None:
-    test_input = "from lib import (a, b, c,)"
+    test_input = "from lib import (a as b,)"
     expected_output = """from lib import (
-    a,
-    b,
-    c,
+    a as b,
 )
 """
 

EDIT: indeed, that reproduces on 8cde8b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix regressions from #2236
2 participants