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

Braces example for multiline conditionals #284

Merged
merged 2 commits into from
Jun 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix typo.
  • Loading branch information
warsaw committed Jun 10, 2017
commit f54cb7fcd06781c926be92a98e6390869913a4ea
2 changes: 1 addition & 1 deletion pep-0007.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Code lay-out

* When you break a long expression at a binary operator, the
operator goes at the end of the previous line, and braces should be
Copy link
Member

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;
        }

Copy link
Member Author

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.

formatted as show. E.g.::
formatted as shown. E.g.::

if (type->tp_dictoffset != 0 && base->tp_dictoffset == 0 &&
type->tp_dictoffset == b_size &&
Expand Down