-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix spotlessApply conflict with black #3152
Conversation
license.eachLine { | ||
w << lineComment | ||
w.writeLine(it) | ||
} | ||
w.writeLine(endComment) | ||
if (endComment.length() > 0 || !isPython) { |
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.
for my own undersanding: what is the purpose of these if conditions? might be misunderstanding but it seems like the end state is this will always write for java and not for python, which is the equivalent to what is being set in the start and end comments for either language.
triimTrailingWhitespace()
by itself is not enough to get rid of the spaces?
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.
In java, we don't have a second linter/styling tool other than spotless so it doesn't really matter if we write a newline or not for startComment/endComment.
However, in python, we are using black that double-checks and reformats the code.
Thus, writing an extra empty newline (not removed by trimTrailingWhitespace()
is actually a big deal and would be reformatted (removed) because in black's specs, there should be exactly one (or two?) empty lines between license header and imports etc
So in python, if you don't use a startComment/endComment syntax, then those lines shouldn't be written at all.
If you do specify some startComment/endComment characters, the lines won't be empty so it should be ok...
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.
Thanks for the explanation!
Makes sense. Can we drop a comment capturing this:
In java, we don't have a second linter/styling tool other than spotless so it doesn't really matter if we write a newline or not for startComment/endComment.
However, in python, we are using black that double-checks and reformats the code.
Thus, writing an extra empty newline (not removed by trimTrailingWhitespace() is actually a big deal and would be reformatted (removed) because in black's specs, there should be exactly one (or two?) empty lines between license header and imports etc
I'm pretty sure I would not remember this after a month heh
Suggestion - maybe simplify the if conditions to just:
if (!isPython) {
w.writeLine(startComment)
}
license.eachLine {
w << lineComment
w.writeLine(it)
}
if (!isPython) {
w.writeLine(endComment)
}
since the python relevant logic is already centralised in createPythonLicenseWith
. I can see argue for checking either parameter, so leave this to your judgement.
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.
tested this locally using ./gradlew :airbyte-integrations:connectors:destination-redshift:build -x test
and this seemed to work!
I have one question for my own understanding before approving.
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 awesome! Thanks Chris!
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.
Thanks, @ChristopheDuong !!!
What
Trying to make spotlessApply on python files equivalent to black formatting...
How
Spotless for python is adding trailing whitespace in headers which is removed by black producing many diffs if one is run and not the other
(seems
airbyte-cdk
was checked in with trailing whitespace so I'm removing them)Recommended reading order
build.gradle