Also an item to ponder - line length. PEP8 says line length should be <= 79 
IIRC.

Black advocates line length of 88, saying it produces least lines of code by 
experience and it’s the default.

https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length



On 2 May 2022, at 23:31, Dave Wallace 
<dwallac...@gmail.com<mailto:dwallac...@gmail.com>> wrote:

I'll work on expanding Klement's patch to include all python files in the repo.

I'm thinking it makes more sense to have a single target 'make 
checkstyle-python' (and corresponding 'fixstyle-python') that runs black 
against all of the '*.py' files in the repo and deprecate the 'test-checkstyle' 
target.  Any objections?

Thanks,
-daw-

On 5/2/22 4:08 PM, Ole Troan wrote:
I’d be happy to have formatting consistency across the project.

Cheers
Ole

On 2 May 2022, at 19:17, Klement Sekera 
<klem...@graphiant.com><mailto:klem...@graphiant.com> wrote:

 +Real Ole.

On 2 May 2022, at 19:15, Klement Sekera via lists.fd.io<http://lists.fd.io/> 
<klement=graphiant....@lists.fd.io<mailto:klement=graphiant....@lists.fd.io>> 
wrote:

Hi Dave,

good catch about requirements.txt. Should be fixed now.

I’m not sure how to proceed with rest of code, seems to be mostly Ole’s domain. 
Thoughts, Ole?

Thanks,
Klement

On 2 May 2022, at 18:50, Dave Wallace 
<dwallac...@gmail.com<mailto:dwallac...@gmail.com>> wrote:

Hi Klement,

I agree that black is a much better PEP8 compliance/formatter for python code.  
I've been using it on my personal python projects for a while now.

I left a minor comment on your gerrit change wrt. installation of pinned 
version as part of the rest of the python virtualenv.  Otherwise it looks good 
to me.

What about the rest of the python code in the repo?

Thanks,
-daw-

On 5/2/22 6:56 AM, Klement Sekera wrote:
Hey vpp-dev,

looking at our current code style and its PEP8 compliance I see a couple of 
issues

1.) it’s not really PEP8 compliant
2.) we have no test-fixstyle

I decided to make it more PEP8 compliant and found out that to just fix W503 to 
W504 (per 
https://peps.python.org/pep-0008/#should-a-line-break-before-or-after-a-binary-operator),
 we would need to do a lot of manual code style changes. Looking at a tool to 
do that I stumbled upon black (https://github.com/psf/black) which aims to be a 
consistent  code style fixer/validator producing minimum diffs. It’s already 
used by many small and large projects and similarly small and large 
organisations. It’s also much faster to validate/format than 
pycodestyle/autopep8 - its runtime on all our files is in seconds.

My proposal is to bite the bullet and accept a change in style in exchange for 
a consistent, auto-formatted, (almost entirely) pep8 compliant style.

Here’s the diff:

https://gerrit.fd.io/r/c/vpp/+/36043

Thoughts?

Thanks,
Klement











-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#21336): https://lists.fd.io/g/vpp-dev/message/21336
Mute This Topic: https://lists.fd.io/mt/90832348/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to