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

black inserts 'unnecessary' newline for consistency #35

Closed
svisser opened this issue Mar 16, 2018 · 4 comments
Closed

black inserts 'unnecessary' newline for consistency #35

svisser opened this issue Mar 16, 2018 · 4 comments

Comments

@svisser
Copy link

svisser commented Mar 16, 2018

Operating system: Mac OS X 10.12.5
Python version: 3.6.1
Black version: 18.3a2
Does also happen on master: Yes

def example(session):
    result = session.query(models.Customer.id).filter(
        models.Customer.account_id == account_id,
        models.Customer.email == email_address,
    ).order_by(
        models.Customer.id.asc(),
    ).all()

becomes:

def example(session):
    result = session.query(models.Customer.id).filter(
        models.Customer.account_id == account_id, models.Customer.email == email_address
    ).order_by(
        models.Customer.id.asc(),
    ).all(
    )

Although the newline in all() is consistent with the other calls above it, I think it's unlikely that the code would be written this way normally.

@svisser
Copy link
Author

svisser commented Mar 16, 2018

I see now that this matches the philosophy described in the README (to make diffs as small as possible). If so then feel free to close this issue.

@ambv
Copy link
Collaborator

ambv commented Mar 16, 2018

I actually have a check not to insert a newline like you are seeing in the last line:
https://github.com/ambv/black/blob/master/black.py#L1199-L1209

I guess it doesn't work quite right. Your intuition was correct, this is not nice formatting. But almost! :-)

I'll fix this for you.

@ambv ambv closed this as completed in bc7109a Mar 17, 2018
@ambv
Copy link
Collaborator

ambv commented Mar 17, 2018

This is now fixed, thanks for your report!

@svisser
Copy link
Author

svisser commented Mar 17, 2018

Thanks for fixing it!

ambv added a commit that referenced this issue Mar 19, 2018
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

No branches or pull requests

2 participants