-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23174][BUILD][PYTHON] python code style checker update #20338
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
Pulling functionality from apache spark
pull latest from apache spark
Pulling functionality from apache spark
Pulling functionality from apache spark
pull request from apache/master
pull latest from apache spark
pull latest from apache spark
Pull apache spark
pull latest apache spark
Apache spark pull latest
|
Test build #86423 has finished for PR 20338 at commit
|
|
This doesn't actually run the Python lint in Jenkins build though because there's no change on the files with diff --git a/dev/run-tests.py b/dev/run-tests.py
index 7e6f7ff0603..6fac324972e 100755
--- a/dev/run-tests.py
+++ b/dev/run-tests.py
@@ -576,7 +576,10 @@ def main():
for f in changed_files):
# run_java_style_checks()
pass
- if not changed_files or any(f.endswith(".py") for f in changed_files):
+ if not changed_files or any(f.endswith("lint-python")
+ or f.endswith("tox.ini")
+ or f.endswith(".py")
+ for f in changed_files):
run_python_style_checks()
if not changed_files or any(f.endswith(".R") for f in changed_files):
run_sparkr_style_checks()too? |
| [pep8] | ||
| ignore=E402,E731,E241,W503,E226 | ||
| [pycodestyle] | ||
| ignore=E402,E731,E241,W503,E226,E722,E741,E305 |
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.
So, do those E722,E741,E305 include rules to validate the blank line before starting doctests, which is described in the JIRA?
Seems:
E722: "do not use bare except'"
E741: "ambiguous variable name 'l'",
E305: "expected 2 blank lines after class or function definition"
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.
These(E722, E741, E305) are new code style standards added that Spark seems to be violating.For now, added them in ignored.I have raised the doctest blank line as an issue under pep8, as it does not belong within Spark.
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.
Ah, I asked this to double check if this PR fixes the issue linked JIRA. I think we could make another JIRA if this PR doesn't target to fix the linked JIRA.
For the best, it'd be nicer if you'd leave a issue link you raised under pep8 in SPARK-11222, and open another JIRA about what this PR changes and then link it by fixing the PR title, if I understood you correctly.
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.
Updated SPARK-11222. Added https://issues.apache.org/jira/browse/SPARK-23174.
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.
should we fix the code that violates
E722: "do not use bare except'"
E741: "ambiguous variable name 'l'",
E305: "expected 2 blank lines after class or function definition"
?
Or that's another PR/JIRA?
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.
Yea .. there look actually many instances about it. I manually ran it against this PR. Will maybe take this one and open a PR separately after double checking each rule. Didn't take a look carefully yet.
dev/lint-python
Outdated
| PEP8_VERSION="2.3.1" | ||
| PEP8_SCRIPT_PATH="$SPARK_ROOT_DIR/dev/pep8-$PEP8_VERSION.py" | ||
| PEP8_SCRIPT_REMOTE_PATH="https://raw.githubusercontent.com/jcrocholl/pep8/$PEP8_VERSION/pep8.py" | ||
| PEP8_SCRIPT_REMOTE_PATH="https://raw.githubusercontent.com/PyCQA/pycodestyle/$PEP8_VERSION/pycodestyle.py" |
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.
Shall we leave a note that pep8 is formally renamed to pycodestyle to reduce confusion, and in the PR description too?
|
Thanks @HyukjinKwon for your review.updated, please verify. |
HyukjinKwon
left a comment
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.
LGTM otherwise.
| sys.exit(int(os.environ.get("CURRENT_BLOCK", 255))) | ||
| else: | ||
| run_cmd([jekyll_bin, "build"]) | ||
|
|
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 know I am insane but let's revert back unrelated changes.
|
Test build #86451 has finished for PR 20338 at commit
|
ueshin
left a comment
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.
LGTM except one question.
dev/lint-python
Outdated
| #+ - Download pep8 from PyPI. It's more "official". | ||
| PEP8_VERSION="1.7.0" | ||
| # Updated to latest official version for pep8.pep8 is formally renamed to pycodestyle. | ||
| PEP8_VERSION="2.3.1" |
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.
Should we also use pycodestyle instead of pep8 for variable names or script names?
|
Test build #86454 has finished for PR 20338 at commit
|
dev/lint-python
Outdated
| #+ TODOs: | ||
| #+ - Download pep8 from PyPI. It's more "official". | ||
| PEP8_VERSION="1.7.0" | ||
| # Updated to latest official version for pep8.pep8 is formally renamed to pycodestyle. |
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.
nit .. : pep8.pep8 -> pep8. pep8
|
(If this also resolves SPARK-11222 you can also include that in the title.) |
|
Ah, seems this one doesn't resolve SPARK-11222 too. I think that JIRA describes to add This JIRA, SPARK-23174, seems describing simply upgrading the pep8 (formally renamed to |
|
@rekhajoshm, mind updating variable names and one nit above? Will merge this one as soon as they are fixed. |
|
@HyukjinKwon @ueshin was bit hesitant to change variable/references as pep8 is very clear within python circles as python style checker.however after pondering, have done the needful. please check.thanks @srowen for SPARK-11222, I had raised a issue under pycodestyle. Created PR #20378 |
|
Test build #86559 has finished for PR 20338 at commit
|
|
Test build #86560 has finished for PR 20338 at commit
|
|
retest this please |
|
Test build #86569 has finished for PR 20338 at commit
|
|
retest this please |
|
Test build #86578 has finished for PR 20338 at commit
|
|
Merged to master. |
…ore file. ## What changes were proposed in this pull request? This is a follow-up pr of apache#20338 which changed the downloaded file name of the python code style checker but it's not contained in .gitignore file so the file remains as an untracked file for git after running the checker. This pr adds the file name to .gitignore file. ## How was this patch tested? Tested manually. Author: Takuya UESHIN <[email protected]> Closes apache#20432 from ueshin/issues/SPARK-23174/fup1.
What changes were proposed in this pull request?
Referencing latest python code style checking from PyPi/pycodestyle
Removed pending TODO
For now, in tox.ini excluded the additional style error discovered on existing python due to latest style checker (will fallback on review comment to finalize exclusion or fix py)
Any further code styling requirement needs to be part of pycodestyle, not in SPARK.
How was this patch tested?
./dev/run-tests