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

Comply with PEP-8 for indentation of parameters in function definition #90

Open
stefanoborini opened this issue Dec 22, 2022 · 3 comments

Comments

@stefanoborini
Copy link

This:

def very_important_function(
    template: str,
    *variables,
    file: os.PathLike,
    debug: bool = False,
):
    code
    code

Should be formatted like this

def very_important_function(
        template: str,
        *variables,
        file: os.PathLike,
        debug: bool = False,
    ):
    code
    code

To comply with PEP-8 indentation directives:

# Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest.
def long_function_name(
        var_one, var_two, var_three,
        var_four):
    print(var_one)
@jni
Copy link

jni commented Apr 19, 2023

@stefanoborini I'm 👍 on this but I do want to point out that your formatting suggestion actually does not comply with PEP8:

The closing brace/bracket/parenthesis on multiline constructs may either line up under the first non-whitespace character of the last line of list, as in:
[...]
or it may be lined up under the first character of the line that starts the multiline construct, as in:
[...]

Not that I blame you, I do actually quite like that construct. But in the spirit of following PEP8 — it bugs me that black explicitly breaks with it so I shouldn't be tempted to do the same when convenient — I think it should be:

def very_important_function(
        template: str,
        *variables,
        file: os.PathLike,
        debug: bool = False,
        ):
    code
    code

This is how I've configured my yapf style. But yapf is no longer maintained. 😭

@jni
Copy link

jni commented Apr 19, 2023

Ah, note that this is actually a duplicate of #89

@jsh9
Copy link

jsh9 commented May 3, 2023

This particular style choice of Black also troubles me. That's what motivated me to start a more configurable formatter based on a fork from Black: https://github.com/jsh9/cercis

My project already supports indenting by 8 spaces at function definitions. And I plan to add more configurable options.

Please feel free to try it out and provide feedback.

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

3 participants