edaniszewski / pylint-quotes

Pylint plugin for checking the consistency of string quotes
MIT License
42 stars 14 forks source link

support smart triple quote escaping #20

Open vapier opened 5 years ago

vapier commented 5 years ago

we normally use """ for our triple quoted strings. but we have a string that ends with a ", so we switched it to '''. we can't end with """" because python stops scanning at the first triple quotes it sees.

since there's smart quoting logic for single/double, there should support for this as well.

# Reduced test case.
f = '''blah "some string"'''

# This is a parse error.
f = """blah "some string""""

# This requires escaping (undesirable).
f = """blah "some string\""""

NB: i'm aware the example doesn't need triple quotes ... our code base actually was multiline strings where triple quotes made sense. this is just a reduced testcase to make it easy to reason about.

vapier commented 5 years ago

looks like nested triple quotes should also be handled (but currently are not)

f = '''some string
with """ in the middle
'''
f = """some string
with ''' in the middle
"""