[
https://issues.apache.org/jira/browse/BEAM-9175?focusedWorklogId=376838&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-376838
]
ASF GitHub Bot logged work on BEAM-9175:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Jan/20 14:03
Start Date: 24/Jan/20 14:03
Worklog Time Spent: 10m
Work Description: kamilwu commented on pull request #10684: [BEAM-9175]
Introduce an autoformatting tool to Python SDK
URL: https://github.com/apache/beam/pull/10684
This PR adds yapf configuration and all the changes made after running it
over the entire Python SDK codebase.
The result is fully compliant with PEP8 (lint check passes, the issues were
manually resolved).
Some of the examples and rules of the newly enforced style (they can be put
under discussion and reviewed):
* Multiple dict entries can be put in the same line.
before:
https://github.com/apache/beam/blob/b689fffa4afcc3b655e1c831d10303b2c89b43dd/sdks/python/apache_beam/io/avroio_test.py#L72-L91
after:
https://github.com/apache/beam/blob/cfa903402e9dd0213e5d837722ce22800c4669f3/sdks/python/apache_beam/io/avroio_test.py#L71-L76
With this setting, it seems the result conforms more to the already used
style (lower number of lines changed).
* Yapf tries to put the first parameter on the same line where the function
begins:
https://github.com/apache/beam/blob/cfa903402e9dd0213e5d837722ce22800c4669f3/sdks/python/apache_beam/utils/annotations_test.py#L56-L61
https://github.com/apache/beam/blob/cfa903402e9dd0213e5d837722ce22800c4669f3/sdks/python/apache_beam/io/gcp/bigquery.py#L398-L407
...unless some of parameters have type annotation or are too long (then it
does the split before the first argument):
https://github.com/apache/beam/blob/cfa903402e9dd0213e5d837722ce22800c4669f3/sdks/python/apache_beam/runners/direct/watermark_manager.py#L129-L136
Indent width is 2 and continuation indent is 4.
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [ ] [**Choose
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and
mention them in a comment (`R: @username`).
- [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA
issue, if applicable. This will automatically link the pull request to the
issue.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more
tips on [how to make review process
smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
Post-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark
--- | --- | --- | --- | --- | --- | --- | ---
Go | [](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/)
| --- | --- | [](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/)
| --- | --- | [](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
Java | [](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/)
Python | [](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/)
| --- | [](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/)
| --- | --- | [](https://builds.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/)
XLang | --- | --- | --- | [](https://builds.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/)
| --- | --- | ---
Pre-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
--- |Java | Python | Go | Website
--- | --- | --- | --- | ---
Non-portable | [](https://builds.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[](https://builds.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/)
| [](https://builds.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/)
Portable | --- | [](https://builds.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/)
| --- | ---
See
[.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md)
for trigger phrase, status and link of all Jenkins jobs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 376838)
Remaining Estimate: 0h
Time Spent: 10m
> Introduce an autoformatting tool to Python SDK
> ----------------------------------------------
>
> Key: BEAM-9175
> URL: https://issues.apache.org/jira/browse/BEAM-9175
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core, sdk-py-harness
> Reporter: Michal Walenia
> Assignee: Kamil Wasilewski
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> It seems there are three main options:
> * black - very simple, but not configurable at all (except for line length),
> would drastically change code style
> * yapf - more options to tweak, can omit parts of code
> * autopep8 - more similar to spotless - only touches code that breaks
> formatting guidelines, can use pycodestyle and flake8 as configuration
> The rigidity of Black makes it unusable for Beam.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)