-
-
Notifications
You must be signed in to change notification settings - Fork 3
STY: clang-format repo #5
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
244f6de
to
12758ea
Compare
@steppi I know there are more important things for you to prioritise, but it would be great if you could check whether any of the formatting configuration looks unacceptably bad here. I think that even getting a non-ideal configuration merged is a big step up from having none at all, as that will allow us to enforce it in CI and make all future formatting automatic. |
the diff is scarily large just due to |
.clang-format
Outdated
ColumnLimit: 120 | ||
InsertNewlineAtEOF: true | ||
AlignAfterOpenBracket: BlockIndent | ||
IncludeBlocks: Preserve | ||
AllowShortFunctionsOnASingleLine: None |
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.
I seem to remember that @izaid deliberately chose a style where short functions could be on a single line. Is there a reason we are changing this now? It mostly effects wrappers like those appearing in config.h.
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.
If I remember correctly, this came from discussions with @fancidev on the superseded PR to SciPy. It was a while ago, though, so not sure
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.
you can take a look at it without adding this option now
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.
I see. From here, scipy/scipy#21640 (comment), it looks like @fancidev only wanted to avoid having short functions automatically converted to one line, but didn't want existing one line wrappers to become split across multiple lines. That's good, it seems everyone is actually in agreement about not including AllowShortFunctionsOnASingleLine: None
. I didn't want to change something that @izaid had explicitly chosen during a period of time where he doesn't have time to participate in discussions.
int acai(std::complex<double>, double, int, int, int, std::complex<double> *, double, double, double, double); | ||
int | ||
acon(std::complex<double>, double, int, int, int, std::complex<double> *, double, double, double, double, double); | ||
int asyi(std::complex<double>, double, int, int, std::complex<double> *, double, double, double, double); |
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.
It seems a little noisy that clang-format will sometimes put the return type on the previous line and sometimes on the same line, in order to keep from exceeding the max column width. I think we should just pick one style and be consistent. Can you see how it looks after setting BreakAfterReturnType
in .clang-format to None
?
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.
done
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.
Huh, that didn't work though. There's still a mix.
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.
I see, None
is deprecated, and now it does something called Automatic
that sometimes does and sometimes doesn't break depending on a penalty calculation. I don't want to fight clang-format so let's just take out BreakAfterReturnType
.
if you would like to test other config options locally, you can do so with |
I made a final update to the clang-format config, cleaned up history with an interactive rebase, and added a commit to add the clang-format commit to |
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.
I think it's good enough. Let's ship it.
thanks Albert! Now lets get the submodule PR in before cherry-picking becomes a nightmare 😅 |
Continues scipy/scipy#21640.
cc @fancidev