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

Ensure that split_on_trailing_comma works with as imports #2340

Merged
merged 5 commits into from
Jan 20, 2025

Conversation

DanielNoord
Copy link
Member

Closes #2338

Took the tests as recommended in #2339

I don't think we should fix the tests by disabling the new profile flag, that would mean that our tests work but anybody using the profile would still get broken imports.
Instead, let's try to fix config.split_on_trailing_comma itself. I believe this does this.

Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.12%. Comparing base (4ae58fa) to head (b96c0ea).
Report is 8 commits behind head on main.

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

Comment on lines +5580 to +5582
test_input = "from lib import (a as b,)"
expected_output = """from lib import a as b
"""
Copy link
Contributor

@matthewhughes934 matthewhughes934 Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's expected for multiple as imports an a trailing comma, e.g. from lib import (a as b, c as d,)?

from lib import a as b
from lib import c as d

or

from lib import (
    a as b,
    c as d,
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current code will do:

from lib import a as b
from lib import c as d

@staticdev
Copy link
Collaborator

@DanielNoord this Django integration test still failimg, did you have time to check if it is related or not to these black changes?

@DanielNoord
Copy link
Member Author

Like I told you in the message: by changing the black style django is no longer conformant. The tests will fail until we release and they reformat their repository.

Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielNoord ok, then we can temporarily disable it and put a comment to re-enable when they upgrade to 6.0.0+

@DanielNoord DanielNoord requested a review from staticdev January 20, 2025 07:56
@DanielNoord
Copy link
Member Author

@staticdev There we go.

I double checked and the offending line is:
/~https://github.com/django/django/blob/ec8cbea91ed6362d43298caa43f3d868452f7efa/django/db/backends/postgresql/compiler.py#L6

django does indeed use the black profile:
/~https://github.com/django/django/blob/ec8cbea91ed6362d43298caa43f3d868452f7efa/pyproject.toml#L61
Which surprised me considering there is a django profile as well...

I think this is fine to merge now :)

Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielNoord LGTM, thanks.

@staticdev staticdev merged commit bced410 into main Jan 20, 2025
38 checks passed
@staticdev staticdev deleted the fix-split-trailing branch January 20, 2025 11:20
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
3 participants