[v1,2/2] doc: increase python max line to 88

Message ID 20221103132926.445627-3-juraj.linkes@pantheon.tech (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series python gitignore and line length |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Juraj Linkeš Nov. 3, 2022, 1:29 p.m. UTC
  88 is a good compromise between shorter files,
readability and other considerations. More in [0].

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

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 .editorconfig                            | 2 +-
 doc/doc_build/meson-private/meson.lock   | 0
 doc/guides/contributing/coding_style.rst | 8 +++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 doc/doc_build/meson-private/meson.lock
  

Comments

Juraj Linkeš Nov. 4, 2022, 9:16 a.m. UTC | #1
Adding folks I forgot to add.

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Thursday, November 3, 2022 2:29 PM
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v1 2/2] doc: increase python max line to 88
> 
> 88 is a good compromise between shorter files, readability and other
> considerations. More in [0].
> 
> [0]
> https://black.readthedocs.io/en/stable/the_black_code_style/current_style
> .html#line-length
> 
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
>  .editorconfig                            | 2 +-
>  doc/doc_build/meson-private/meson.lock   | 0
>  doc/guides/contributing/coding_style.rst | 8 +++++++-
>  3 files changed, 8 insertions(+), 2 deletions(-)  create mode 100644
> doc/doc_build/meson-private/meson.lock
> 
> diff --git a/.editorconfig b/.editorconfig index ab41c95085..f20996f329 100644
> --- a/.editorconfig
> +++ b/.editorconfig
> @@ -16,7 +16,7 @@ max_line_length = 100
>  [*.py]
>  indent_style = space
>  indent_size = 4
> -max_line_length = 79
> +max_line_length = 88 #
> +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> +le.html#line-length
> 
>  [meson.build]
>  indent_style = space
> diff --git a/doc/doc_build/meson-private/meson.lock
> b/doc/doc_build/meson-private/meson.lock
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/doc/guides/contributing/coding_style.rst
> b/doc/guides/contributing/coding_style.rst
> index 89db6260cf..7620268dc7 100644
> --- a/doc/guides/contributing/coding_style.rst
> +++ b/doc/guides/contributing/coding_style.rst
> @@ -851,7 +851,13 @@ Python Code
>  All Python code should be compliant with
>  `PEP8 (Style Guide for Python Code)
> <https://www.python.org/dev/peps/pep-0008/>`_.
> 
> -The ``pep8`` tool can be used for testing compliance with the guidelines.
> +The ``pep8`` tool can be used for testing compliance with the
> +guidelines. Note that the maximum line length is 88, as that is a good
> +compromise between shorter files, usability with other tools (side-by-side
> diffs, docs, presentations) and disability accommodation.
> +More in `Black's documentation
> +<https://black.readthedocs.io/en/stable/the_black_code_style/current_st
> yle.html#line-length>`_.
> +
> +..
> 
>  Integrating with the Build System
>  ---------------------------------
> --
> 2.30.2
  
Bruce Richardson Nov. 4, 2022, 9:28 a.m. UTC | #2
On Fri, Nov 04, 2022 at 09:16:13AM +0000, Juraj Linkeš wrote:
> Adding folks I forgot to add.
> 
> > -----Original Message-----
> > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Sent: Thursday, November 3, 2022 2:29 PM
> > Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Subject: [PATCH v1 2/2] doc: increase python max line to 88
> > 
> > 88 is a good compromise between shorter files, readability and other
> > considerations. More in [0].
> > 
> > [0]
> > https://black.readthedocs.io/en/stable/the_black_code_style/current_style
> > .html#line-length
> > 
> > Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > ---

Personally, if we move beyond 80 chars, I'd prefer to go all the way to
100, but I'm not going to argue about it. Happy enough to go with 88 for
now.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Stephen Hemminger Nov. 4, 2022, 4:57 p.m. UTC | #3
On Fri, 4 Nov 2022 09:16:13 +0000
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:

> > +max_line_length = 88 #
> > +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> > +le.html#li

Skip the comment, it caused your line break!
  
Juraj Linkeš Nov. 10, 2022, 9:15 a.m. UTC | #4
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, November 4, 2022 5:58 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Owen Hilyard
> <ohilyard@iol.unh.edu>; thomas@monjalon.net; Lijuan Tu
> <lijuan.tu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> dev@dpdk.org
> Subject: Re: [PATCH v1 2/2] doc: increase python max line to 88
> 
> On Fri, 4 Nov 2022 09:16:13 +0000
> Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> 
> > > +max_line_length = 88 #
> > >
> +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> > > +le.html#li
> 
> Skip the comment, it caused your line break!

The fact that the line is a bit longer does not make the line less readable, as the link is there to be copy-pasted (and I don't think anyone reads the full hyperlinks - the knowledge of domain is enough). As such I think it's better to include the link as it serves as self-documentation (that we're deviating from the standard).

We could move the comment before or after the max_line_length option and that would result in lines below 100 characters (which is what .editorconfig prescribes). I used that in my one of my local versions, but it was less readable in my opinion. I'd rather break the rule and have it be more readable.

Of course, not having the comment is fine, since we document it in the coding style guide. I just think there's no (or very little) downside and some upside (more than downside) in adding the comment.
  
Stephen Hemminger Nov. 10, 2022, 4:27 p.m. UTC | #5
On Thu, 10 Nov 2022 09:15:16 +0000
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Friday, November 4, 2022 5:58 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Owen Hilyard
> > <ohilyard@iol.unh.edu>; thomas@monjalon.net; Lijuan Tu
> > <lijuan.tu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> > dev@dpdk.org
> > Subject: Re: [PATCH v1 2/2] doc: increase python max line to 88
> > 
> > On Fri, 4 Nov 2022 09:16:13 +0000
> > Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> >   
> > > > +max_line_length = 88 #
> > > >  
> > +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty  
> > > > +le.html#li  
> > 
> > Skip the comment, it caused your line break!  
> 
> The fact that the line is a bit longer does not make the line less readable, as the link is there to be copy-pasted (and I don't think anyone reads the full hyperlinks - the knowledge of domain is enough). As such I think it's better to include the link as it serves as self-documentation (that we're deviating from the standard).
> 
> We could move the comment before or after the max_line_length option and that would result in lines below 100 characters (which is what .editorconfig prescribes). I used that in my one of my local versions, but it was less readable in my opinion. I'd rather break the rule and have it be more readable.
> 
> Of course, not having the comment is fine, since we document it in the coding style guide. I just think there's no (or very little) downside and some upside (more than downside) in adding the comment.

The choice of max line length is project specific. Referencing some other style guide
doesn't seem necessary.  My choice would be to use 100 like the other C code.
  

Patch

diff --git a/.editorconfig b/.editorconfig
index ab41c95085..f20996f329 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@  max_line_length = 100
 [*.py]
 indent_style = space
 indent_size = 4
-max_line_length = 79
+max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
 
 [meson.build]
 indent_style = space
diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 89db6260cf..7620268dc7 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -851,7 +851,13 @@  Python Code
 All Python code should be compliant with
 `PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
 
-The ``pep8`` tool can be used for testing compliance with the guidelines.
+The ``pep8`` tool can be used for testing compliance with the guidelines. Note that the
+maximum line length is 88, as that is a good compromise between shorter files, usability
+with other tools (side-by-side diffs, docs, presentations) and disability accommodation.
+More in `Black's documentation
+<https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length>`_.
+
+..
 
 Integrating with the Build System
 ---------------------------------