-
Notifications
You must be signed in to change notification settings - Fork 378
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
[#3206]improvement(client-python): Add Black for client-python #3254
Conversation
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.
@noidname01 Thank you for you improving code style of Gravitino Python client.
Now Python code become to neat and elegant.
clients/client-python/gravitino/dto/requests/metalake_create_request.py
Outdated
Show resolved
Hide resolved
@noidname01 what is the relationship between pylint and black? How do we trigger this in gradle? |
@jerryshao Currently the This pipeline was manually defined to run before |
black is integrated into spotless, can we use spotless one? |
I had just survey the spotless Python solution and I found it need to manually install |
I see, thanks for the explain. |
I've add |
|
||
matching { | ||
it.name.endsWith("envSetup") | ||
}.all { | ||
// add install package and code formatting before any tasks | ||
finalizedBy(pipInstall, black, pylint) | ||
} |
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.
Which mean are these codes?
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.
hi @noidname01 I didn't found envSetup
task in you PR.
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 envSetup
task is from VenvTask
, this task is respnsible for python virtual environment setup, so I think it's a great entry to bind our pipeline before running all the other tasks.
The source code is here.
@noidname01 sorry for late response. It is not needed for |
@jerryshao Oh I think I gave you wrong idea because of my expression, what I mean is we only need to run python code formatting pipeline when needed, not including the |
[FORMAT] | ||
|
||
# Maximum number of characters on a single line. | ||
max-line-length=120 |
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.
II would suggest to change to 100 to align with our java code. WDYT @noidname01 @xunliu , what is the typical length of python code?
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 because Black
seems not to format the length of docstrings but Pylint
will complain about it.
There are many long docstrings in current project, I can try to refine them, But I think this PR has done too many modifications, maybe finish in follow-up PRs ?
BTW, the max length is defined as 79 characters each line in PEP8(Python Standard Library Code Style), and the default setting of Black is 88.
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, you can do it in a separate PR. the default length seems too short, if so I would suggest to align with Java code to use 100.
I tried it locally, generally LGTM, just have a minor comment. @xunliu would you please take a deep look when you have time? |
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.
@noidname01 Thank you for your contributions.
LGTM
@noidname01 would you please create a PR to cherry-pick this merged commit to branch-0.5. |
…pache#3254) ### What changes were proposed in this pull request? * Add Black as code formatter, it enforce the coding style with 1. trailing commas and whitespaces 2. unified quotation marks(") 3. new lines 4. max line length 5. indents * Aligned with Pylint Rules * Add Black into Gradle and form a code formatting pipeline (pipInstall -> Black -> Pylint), this pipeline will run implicitly in `build` and `test` gradle tasks. > Note that Black still can't format long entire string exceeding `max line length` without enabling unstable features, please handle long strings with caution and make Pylint to ignore them if they are really necessary. ### Why are the changes needed? Fix: apache#3206, apache#3203 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No --------- Co-authored-by: TimWang <[email protected]>
#3325) ### What changes were proposed in this pull request? * Add Black as code formatter, it enforce the coding style with 1. trailing commas and whitespaces 2. unified quotation marks(") 3. new lines 4. max line length 5. indents * Aligned with Pylint Rules * Add Black into Gradle and form a code formatting pipeline (pipInstall -> Black -> Pylint), this pipeline will run implicitly in `build` and `test` gradle tasks. > Note that Black still can't format long entire string exceeding `max line length` without enabling unstable features, please handle long strings with caution and make Pylint to ignore them if they are really necessary. ### Why are the changes needed? Fix: #3206, #3203 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No Co-authored-by: TimWang <[email protected]>
…pache#3254) ### What changes were proposed in this pull request? * Add Black as code formatter, it enforce the coding style with 1. trailing commas and whitespaces 2. unified quotation marks(") 3. new lines 4. max line length 5. indents * Aligned with Pylint Rules * Add Black into Gradle and form a code formatting pipeline (pipInstall -> Black -> Pylint), this pipeline will run implicitly in `build` and `test` gradle tasks. > Note that Black still can't format long entire string exceeding `max line length` without enabling unstable features, please handle long strings with caution and make Pylint to ignore them if they are really necessary. ### Why are the changes needed? Fix: apache#3206, apache#3203 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No --------- Co-authored-by: TimWang <[email protected]>
### What changes were proposed in this pull request? * Add Black as code formatter, it enforce the coding style with 1. trailing commas and whitespaces 2. unified quotation marks(") 3. new lines 4. max line length 5. indents * Aligned with Pylint Rules * Add Black into Gradle and form a code formatting pipeline (pipInstall -> Black -> Pylint), this pipeline will run implicitly in `build` and `test` gradle tasks. > Note that Black still can't format long entire string exceeding `max line length` without enabling unstable features, please handle long strings with caution and make Pylint to ignore them if they are really necessary. ### Why are the changes needed? Fix: #3206, #3203 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No --------- Co-authored-by: TimWang <[email protected]> (cherry picked from commit a88a361)
What changes were proposed in this pull request?
build
andtest
gradle tasks.Why are the changes needed?
Fix: #3206, #3203
Does this PR introduce any user-facing change?
No
How was this patch tested?
No