Re: [PATCH] doc-rst: kernel-doc directive, fix state machine reporter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 21.07.2016 um 00:54 schrieb Jonathan Corbet <corbet@xxxxxxx>:

> On Wed, 20 Jul 2016 12:38:58 +0200
> Markus Heiser <markus.heiser@xxxxxxxxxxx> wrote:
> 
>> Add a reporter replacement that assigns the correct source name and line
>> number to a system message, as recorded in a ViewList.
> 
> This is clearly a worthwhile fix, and I've applied it.  A couple of little
> notes, though...
> 
>> +          self.state.memo.title_styles, self.state.memo.section_level = [], 0
> 

Hi Jon, 

thanks for your review / accept.

> Kernel coding style doesn't really extend to Python, but I believe this
> sort of multiple assignment goes against its spirit.

its a tuple assignment ;)

>  In the future, can we
> just do it as two lines?

Yes, in this case its a bad style, because it really is a multiple
assignment.

Sometimes I use tuple assignments for readability. E.g in the
first and last line, where I buffer (buf) the self.state.memo 
properties:

+            buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
+            self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
+            self.state.memo.title_styles, self.state.memo.section_level = [], 0
+            try:
+                self.state.nested_parse(result, 0, node, match_titles=1)
+            finally:
+                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf


> 
>> -        except Exception as e:
>> +        except Exception as e:  # pylint: disable=W0703
>>             env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
>>                          (" ".join(cmd), str(e)))
>>             return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
> 
> This hunk would appear to be an unrelated change?

This is from my pylint run and brings me to the point *linting*
To cover style and quality aspects, I advise to use pylint !

  https://www.pylint.org/

E.g. in Emacs use "M-x pylint" to lint current buffer. Pylint 
integrates error detection (quality) and Coding Standard (PEP8) 
check:

 https://www.python.org/dev/peps/pep-0008/

I'am not familiar with all details of the kerne Coding Standards
but I guess that PEP8 will cover most similar in the python domain.

The main motivation of PEP 8 is readability. Taking this into account
our python implementations has weakness, e.g. large try/except blocks
and catching unclassified exception (see above). Catching unclassified
will be criticized by pylint. Sometimes we need to catch unclassified.
With the "# pylint: disable=W0703" I deactivate the pylint message W0703

 http://pylint-messages.wikidot.com/messages:w0703

-- Markus --


> 
> Thanks,
> 
> jon

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux