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

if-expression line breaks in function arguments #2561

Closed
gsnedders opened this issue Oct 22, 2021 · 1 comment
Closed

if-expression line breaks in function arguments #2561

gsnedders opened this issue Oct 22, 2021 · 1 comment
Labels
F: linebreak How should we split up lines? T: style What do we want Blackened code to look like?

Comments

@gsnedders
Copy link

Describe the style change

Currently, if an if-expression within a function call needs to be broken across lines to avoid being an overly long line, it gets put horizontally in line with arguments which makes it hard to see where each argument in the call begins.

Examples in the current Black style

            yield Test(
                test_path=trimmed_path,
                expected_text_path=expected_text_paths[-1]
                if expected_text_paths
                else None,
                expected_audio_path=expected_audio_paths[-1]
                if expected_audio_paths
                else None,
                expected_image_path=expected_image_paths[-1]
                if expected_image_paths
                else None,
                reference_files=sorted(reference_files[-1])
                if reference_files
                else None,
                is_http_test="http/test" in trimmed_path,
                is_websocket_test="websocket/" in trimmed_path,
                is_wpt_test=(
                    "imported/w3c/web-platform-tests/" in trimmed_path
                    or "http/wpt/" in trimmed_path
                ),
            )

Desired style

            yield Test(
                test_path=trimmed_path,
                expected_text_path=expected_text_paths[-1]
                    if expected_text_paths
                    else None,
                expected_audio_path=expected_audio_paths[-1]
                    if expected_audio_paths
                    else None,
                expected_image_path=expected_image_paths[-1]
                    if expected_image_paths
                    else None,
                reference_files=sorted(reference_files[-1])
                    if reference_files
                    else None,
                is_http_test="http/test" in trimmed_path,
                is_websocket_test="websocket/" in trimmed_path,
                is_wpt_test=(
                    "imported/w3c/web-platform-tests/" in trimmed_path
                    or "http/wpt/" in trimmed_path
                ),
            )

(I'm not really beholden to this specific option to make it clear where each argument is, but I do really think it should be clearer.)

@gsnedders gsnedders added the T: style What do we want Blackened code to look like? label Oct 22, 2021
@felix-hilden
Copy link
Collaborator

Hi! This is a duplicate of #2248, so I'll close it. Let's continue the discussion there.

@ichard26 ichard26 added the F: linebreak How should we split up lines? label Oct 22, 2021
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? T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

3 participants