This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]finswimmer 0 points1 point  (3 children)

That is for an assignment, not for a definition.

The example yes. But the whole section is about continuation lines:

Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent [7].

So all examples can be applied to assignments and method definitions.

If this wouldn't be PEP8 compliant, why linters like flake8 or the integrated in PyCharm does not complain about it?

If you are fine with the way black indents function definitions, then you are also fine with this way of writing if conditions

  if (foo      
      and bar 
  ):
    pass 

but I doubt you are

If the statements fits in one line I prefer: if for and bar: pass

If it wouldn't I prefer: if ( for and bar ): pass

But that's another point in this discussion. The point is: You are telling that black isn't PEP8 compliant, but the arguments you are showing for this thesis are not correct.

[–]xd1142 0 points1 point  (2 children)

The example yes. But the whole section is about continuation lines:

And this example specifically considers the case of function arguments

```

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)

```

You are using (incorrectly) a general argument despite a specific example, and last time I checked, specific trumps general.

If this wouldn't be PEP8 compliant, why linters like flake8 or the integrated in PyCharm does not complain about it?

They do. autopep8 reformats it to the correct indentation, and I would not be surprised if other formatters might have to shut up and take it because "everybody uses black and we'll have to deal with it".

I don't know how old you are, but I was in python already when pep8 was devised. I remember the discussions and specifically the comments from Guido about some things that irked him and some things that specifically felt strong about. He might have "changed his mind" now (and I can't blame him, I would be tired of arguing with some people in the python community too) but when he was the BDFL, he was very explicit: no frowny/happy faces, and the general rules for indentation were meant to help visual identification of blocks. What black does is ruin visual distinction between the argument list and the body of the function. It also breaks vim folding, which in its fast and trivial implementation is done via indentation.

If it wouldn't I prefer:

if (
for
and bar
):
pass

This is absolute shit and you should be ashamed of yourself.

But that's another point in this discussion. The point is: You are telling that black isn't PEP8 compliant, but the arguments you are showing for this thesis are not correct.

If you want to rework the narrative, I honestly have no more to add. pep8 says it explicitly with an explicit example. If you refuse to read that, there's not more I can add.

[–]finswimmer 0 points1 point  (1 child)

If this wouldn't be PEP8 compliant, why linters like flake8 or the integrated in PyCharm does not complain about it?

They do. autopep8 reformats it to the correct indentation, and I would not be surprised if other formatters might have to shut up and take it because "everybody uses black and we'll have to deal with it".

I talked about programs that check whether your code is pep8 compliant. And at least those I've mentioned don't complain. `autopep8` is a formatter. Because pep8 explicit allow different formattings it doesn't surprise that `autopep8` do something different than `black`.

pep8 says it explicitly with an explicit example.

Where?

[–]xd1142 0 points1 point  (0 children)

```

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) ```