-
Notifications
You must be signed in to change notification settings - Fork 4.5k
adds pre-commit hook to standardize whitespaces, adds EditorConfig to set the indents #35564
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
Conversation
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
I don't think the GitHub action failures are related to my code changes. |
|
assign set of reviewers |
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
You've impacted 1,775 files here, I'm assuming by applying the whitespace linting to the entire code base (although I have no clue how you managed to also impact things like SVGs for the website.) I would suggest narrowing the scope significantly, as A) I'd prefer to not impact |
e3af23b to
b38afdc
Compare
Thanks Jack for your feedback and perspective here (also enjoyed your session when you spoke at Beam Summit too). For SVGs, they are ultimately text files too, not binary files. So, applying the whitespace rules to them seems fair in my opinion. Fwiw, there were many SVGs that did not require any changes which means that they already follow these new linting rules. So, in my opinion, enforcing consistency here is a good thing. If you prefer my changes to not effect the existing git blame, I could create a separate pr after this one to add the git hash for this merged change to an ignore file. You can see an example from another Apache project, Apache Airflow, here. Finally, I do not think any human should try to manually review the whitespace changes in this pr. To make it easier to, I have pushed 4 separate commits that should allow you to review the non-whitespace changes separately. Let's go through each of them. 2f6d47d (
be0f635 (
0029f5f (
b38afdc (
Okay, after walking through each commit and running the pre-commit command locally yourself, I think you can have more confidence in my change. But how do we know that the pre-commit hook I am adding does what it says.
Finally, in order for this to be beneficial, I think we need we need to be running the Separately, I did this script |
|
Reminder, please take a look at this pr: @jrmccluskey @m-trieu @shunping @Abacn @kennknowles @johnjcasey |
|
Hey @nyoungstudios I think we already have tooling to cover linting and whitespace in our repo (specifically for python this is covered via tox + some other linting checks - https://cwiki.apache.org/confluence/display/BEAM/Python+Tips#PythonTips-LintandFormattingChecks) I'm not sure we need more linting rules in the repo, and I'm hesitant to ask people to update their regular workflows to accomodate this when there's not much of a value add. |
|
Reminder, please take a look at this pr: @jrmccluskey @m-trieu @shunping @Abacn @kennknowles @johnjcasey |
|
Closing per my last comment - feel free to comment if you disagree |
|
Thanks @damccorm for the review. Sorry for the delayed response as I got busy with other things. Obviously, I am not an active contributor here; so, if you guys don't think this is worth adding then that is fine with me. I will say that even though this repo does have linting for Python, my updates in this pr showed that the current tools being used still miss some whitespace. If I were a code reviewer where there could be inconsistency in whitespace, I would fine that annoying. But I don't really mind that much since I am not a code reviewer here. I will say that my biggest complaint when first contributing Python code to this repo is that it uses 2 spaces for a tab opposed to most Python projects and Python IDEs that default to 4 spaces. With that in mind, do you think I could make this pr (or open another pr) for just the Lots of other popular repos on GitHub use an |
|
Sure, adding this seems fine, thanks |
|
Thanks, I've opened the updated pr here: #35956 |
Please add a meaningful description for your change here
Adds
.editorconfigModifies
.pre-commit-config.yamlAll other changes where modified by running
pre-commit run -all-filesFor more details, keep reading:
Adds a pre-commit hook to standardize whitespaces, so we don't have stray new lines or missing new line at the end of the file, or stray spaces at the end of a line
Adds an
.editorconfigfile with these same settings. Previously, I found it harder to contribute to the Python codebase since the default Python indent is 4 spaces, but this project uses 2 spaces. So, adding the EditorConfig will let your code editor like VS Code or PyCharm automatically pick up this project's settings. VS Code you need to install the code extension, but PyCharm does have this built in.It seems that we also don't need the
sdks/python/scripts/run_whitespacelint.shanymore with this change. But I wasn't quite sure how to remove it from thebuild.gradleyet. And for what it is worth, it is using https://github.com/bendikro/whitespacelint which doesn't look maintained.Also, I wasn't exactly sure how the
.pre-commit-config.yamlwas being run in the GitHub actions or if it was at all since there were comments in the.pre-commit-config.yamlreferencing to keep the yapf and pylint versions synced elsewhere.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.