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

Too much whitespace when last or only param to a function/method call is a payload dict func({...}) #2724

Closed
fmalina opened this issue Dec 23, 2021 · 5 comments
Labels
F: linebreak How should we split up lines? R: duplicate This issue or pull request already exists T: style What do we want Blackened code to look like?

Comments

@fmalina
Copy link

fmalina commented Dec 23, 2021

Describe the style change

I'd like black use more terse formatting when it comes across dictionaries as params in function and method calls. Here's a django function based view example, function calls accepting payload dicts end up looking wrong

Example in the current Black style

def view(request):
    ...
    return render(
        request,
        'places/detail.html',
        {
            'place': place,
            'opening_times': times,
            'photos': photos,
            'staff': staff,
            'town': town,
            'segment': sector,
        },
    )

Desired style

def view(request):
    ...
    return render(request, 'places/detail.html', {
        'place': place,
        'opening_times': times,
        'photos': photos,
        'staff': staff,
        'town': town,
        'segment': sector
    })
@fmalina fmalina added the T: style What do we want Blackened code to look like? label Dec 23, 2021
@felix-hilden
Copy link
Collaborator

Hi! How would you suggest we format calls with an argument after an exploded collection? I'd argue it should take the current form. But you could make a case for the suggested formatting only if the last argument is exploded.

@fmalina
Copy link
Author

fmalina commented Dec 23, 2021

I can't imagine the former without an example, but I would agree with the latter

@felix-hilden
Copy link
Collaborator

This I would expect to stay as it is.

def view(request):
    ...
    return render(
        request,
        'places/detail.html',
        {...},
        some_other_argument,  # after collection to be exploded
    )

I'm open to making an exception for the last argument, but I'm quite happy with our current formatting as well. Thoughts by others?

@ichard26 ichard26 added the F: linebreak How should we split up lines? label Dec 26, 2021
@fmalina
Copy link
Author

fmalina commented Dec 27, 2021

I have just had a super rare case like you show above where dictionary argument was followed by another and I went with current black style formatting too

@felix-hilden
Copy link
Collaborator

I think this is sufficiently similar to #1811 so that we can close this. I'll include your case in the discussion as well. Hopefully we'll get to resolving it one way or the other!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: linebreak How should we split up lines? R: duplicate This issue or pull request already exists T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

3 participants