-
Notifications
You must be signed in to change notification settings - Fork 461
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
Add autoformatting to the PgBouncer source code #892
Conversation
6df4dba
to
7020445
Compare
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 is not a complete review because it is easy to bikeshed on topics like this.
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.
This is very impressive. I'm happy to proceed with this tool. I left a few small comments on the formatting itself. The source code and build system integration needs a bit more consideration.
.gitmodules
Outdated
@@ -4,3 +4,6 @@ | |||
[submodule "uthash"] | |||
path = uthash | |||
url = https://github.com/troydhanson/uthash.git | |||
[submodule "uncrustify"] |
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 would rather have fewer submodules than more. But apart from that, pulling this in this way would include it in the distributed source tarballs, which isn't good. Also, it's GPL. So we should really keep it at arm's length. Better just install it as a normal build dependency.
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.
The main problem with installing a system uncrustify version through apt
/yum
/brew
is that it is important that everyone uses the exact same version. A newer version might have a formatting bug fixed and result in slightly different formatting. So a submodule seemed like a reasonable way to ensure a consistent version. (for black this is less of an issue, because we can just say we should use the latest version, which is very easy to install using pip
)
But apart from that, pulling this in this way would include it in the distributed source tarballs, which isn't good.
You mean the ones created by make dist
? Since it's not in the EXTRA_DIST
list they won't be included there. Also github doesn't seem to include submodule contents in the source tarballs it generates.
Also, it's GPL. So we should really keep it at arm's length. Better just install it as a normal build dependency.
Since we're not linking against it (only executing the built binary) I personally don't see much of an issue with it.
To resolve concerns though, I now pushed a version where we get the tarball from github and compile the uncrustify
binary in a temporary directory.
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.
We can just say, we use uncrustify version x.y.z, and everyone just has to get that one.
I hate git submodules and I don't want more git submodules. :)
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.
Did you see I updated the the PR to remove the submodule and have the make target fetch and compile the uncrustify version from sources in a temporary directory? Is that okay? Or would you rather I remove the install steps from the Makefile
completely and instead move them to a CONTRIBUTING.md
and have people run them manually?
@@ -177,3 +177,21 @@ htmls: | |||
|
|||
doc/pgbouncer.1 doc/pgbouncer.5: | |||
$(MAKE) -C doc $(@F) | |||
|
|||
indent-check: uncrustify/build/uncrustify | |||
flake8 |
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.
Seems like flake8 isn't really related to indenting.
.cirrus.yml
Outdated
@@ -260,14 +260,14 @@ task: | |||
type: text/plain | |||
|
|||
task: | |||
name: Python check | |||
name: Formatting check |
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 would like to keep the Python style check separate from the formatting checks.
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.
Did you mean Python and C separate? and/or did you mean separating flake8
(which does not format automatically) from isort
& black
?
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 split stuff up a bit more. Is this what you had in mind?
pyproject.toml
Outdated
@@ -19,9 +19,21 @@ timeout = 30 | |||
# versions is a small price to pay to not have to worry about that. | |||
asyncio_mode = 'auto' | |||
|
|||
# Make test discovery quicker | |||
norecursedirs = [ | |||
'*.egg', |
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.
unrelated to this patch?
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.
uncrustify directory had a python file that caused some issues with this I think
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.
Yeah, I don't want uncrustify's stuff in pgbouncer's tree. We have enough crap in there, we don't need to import someone else's crap too and then keep track of that as versions change.
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.
Yeah fair enough, I had already updated the PR to have a make target to compile it in a temporary directory. But I forgot to remove these changes. I did that now. And I created a separate PR to update the excludes for the already existing submodules: #924
Makefile
Outdated
flake8 | ||
black --check . | ||
isort --check . | ||
uncrustify/build/uncrustify -c uncrustify.cfg --check include/*.h src/*.c -L WARN |
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.
Also, it would be good to make separate targets for C code and Python code. Most people will only deal with the C code, so it would be annoying to make them download black and isort, or manually copy the uncrustify command.
a8da877
to
b7c522d
Compare
b7c522d
to
2807171
Compare
@petere I think I addressed all feedback. |
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.
Ok by me.
Please check if the changes in .flake8
and pyproject.toml
are still required.
It seems this was done. :) |
Just to be clear, you're happy with the current method of installing uncrustify? (i.e. Makefile that fetches and compiles tarball in a temp directory, and puts the final binary in the root of the repo) |
Let's say I'm "content". :) |
This was missed in pgbouncer#892, because these new lines were added after the last rebase of that PR (and they did not cause a merge conflict).
This was missed in #892, because these new lines were added after the last rebase of that PR (and they did not cause a merge conflict).
This uses uncrustify with a config that matches the code style of the repo as
close as I was able to configure it.
Codestyle is always an easy thing to disagree on, but I think overall this
improves the styling. It also keeps the fairly small.
I also considered using pgindent, but that requires a typedefs.list which is a
pain to create. The current codestyle of PgBouncer also doesn't match the one
from Postgres at all, so it would cause many uninteresting changes.