> but I'd like to understand why yapf lets breakable lines go longer than
80 chars.

I filed an issue with yapf [1] to see if we can figure this out.

> Whatever the decision is, please update the instructions here :)

Will do!

Brian

[1] https://github.com/google/yapf/issues/927

On Fri, Apr 9, 2021 at 5:35 PM Alex Amato <[email protected]> wrote:

> Whatever the decision is, please update the instructions here :)
> https://cwiki.apache.org/confluence/display/BEAM/Python+Tips
>
> (And if possible let's have one simple, easy to remember command to run
> all python lint/formatting). Possibly using a wrapper script.
>
>
> On Fri, Apr 9, 2021 at 4:59 PM Robert Bradshaw <[email protected]>
> wrote:
>
>> I'd be happy with yapf + docformatter + isort, but I'd like to understand
>> why yapf lets breakable lines go longer than 80 chars.
>>
>> On Fri, Apr 9, 2021 at 4:19 PM Brian Hulette <[email protected]> wrote:
>>
>>> Currently we have two different format checks for the Python SDK. Most
>>> format checks are handled by yapf, which is nice since it is also capable
>>> of re-writing the code to make it pass the checks done in CI. However we
>>> *also* have some formatting checks still enabled in our .pylintrc [1], and
>>> pylint has no such capability.
>>>
>>> Generally yapf's output just passes these pylint format checks, but not
>>> always. For example yapf is lenient about lines over the column limit, and
>>> pylint is not. So things like [2] can happen even on a PR formatted by
>>> yapf. This is frustrating because it requires manual changes.
>>>
>>> I experimented with the yapf config to see if we can make it strict
>>> about the column limit, but it doesn't seem to be possible. So instead I'd
>>> like to propose that we just remove the pylint format checks, and rely on
>>> yapf's checks alone.
>>>
>>> There are a couple issues here:
>>> - we'd need to be ok with yapf deciding that some lines can be >80
>>> characters
>>> - yapf has no opinion whatsoever about docstrings [3], so the only thing
>>> checking them is pylint. We might work around this by setting up
>>> docformatter [4].
>>>
>>> Personally I'm ok with this if it means Python code formatting can be
>>> completely automated with a single script that runs yapf, docformatter, and
>>> isort.
>>>
>>> Brian
>>>
>>> [1]
>>> https://github.com/apache/beam/blob/2408d0c11337b45e289736d4d7483868e717760c/sdks/python/.pylintrc#L165
>>> [2]
>>> https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Commit/9088/console
>>> [3] https://github.com/google/yapf/issues/279
>>> [4] https://github.com/myint/docformatter
>>>
>>

Reply via email to