Open NeilGirdhar opened 5 months ago
For completeness, can you give an example of the pattern you want to lint against, and the suggested alternative?
Sure, from the CPython source:
if self.size_read == self.chunksize and \
self.align and \
(self.chunksize & 1):
dummy = self.file.read(1)
I prefer:
if (self.size_read == self.chunksize and self.align
and (self.chunksize & 1)):
dummy = self.file.read(1)
Of course, it's a matter of opinion, but apparently according a core developor:
Guido and other core developers are not fans of using backslash to negate line-ends. Not only do fence pairs (parentheses, brackets, and braces) negate all contained line-ends, but the use of grouping parentheses has been expanded to eliminate most/all needs for line-end backslashes. For instance, 3.10 added the use of grouping parentheses to write with statements over multiple lines without using backslash. AFAIK, this was the last required use of backslash, line-end in normal code.
Not a 'decision' but as a heads up I'm generally hesitant to add more rules that are made redundant with the formatter.
The continuation character used outside of strings are no longer necessary as of Python 3.9 thanks to the new PEG parser. This means that we can always use parentheses. And parentheses have the advantage of not interfering with comments, and for some people are easier to read.
Also, doing a grep on Python source suggests that many Python programmers are preferring parenthesis continuations—except in strings.
Would it make sense to warn on them?