According to guido (and to some other Python programmers), implicit string literal concatenation is considered harmful. Thus, I am trying to identifying logical lines containing such a concatenation.
My first (and only) attempt was using shlex
; I thought of splitting a logical line with posix=False
, so I'll identify parts encapsulated by quotes, and if these lie next to each other, it will be considered "literal concatenation".
However, this fails on multiline strings, as the following example shows:
shlex.split('""" Some docstring """', posix=False)
# Returns '['""', '" Some docstring "', '""']', which is considered harmful, but it's not
I can tweak this is some weird ad-hoc ways, but I wondered whether you can think of a simple solution for this. My intention is to add it to my already extended pep8
verifier.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…