-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Braces example for multiline conditionals #284
Conversation
@@ -124,11 +124,13 @@ Code lay-out | |||
type->tp_name); | |||
|
|||
* When you break a long expression at a binary operator, the | |||
operator goes at the end of the previous line, e.g.:: | |||
operator goes at the end of the previous line, and braces should be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think the brace should be moved only if the indentation of continuation lines matches the indentation of the following code. In the following case the brace should be kept at the end of the line:
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"invalid escape sequence '\\%c'",
*first_invalid_escape) < 0) {
Py_DECREF(result);
return NULL;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually looks a bit weird to me, though I can understand the rationale. I'd personally prefer a rule that states the open brace not to be hanging in all multiline conditional cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My heuristic is { on the if line, but on on a newline if the if takes at least 2 lines.
pep-0007.txt
Outdated
@@ -124,11 +124,13 @@ Code lay-out | |||
type->tp_name); | |||
|
|||
* When you break a long expression at a binary operator, the | |||
operator goes at the end of the previous line, e.g.:: | |||
operator goes at the end of the previous line, and braces should be | |||
formatted as show. E.g.:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 'as shown'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
Closes #283