Skip to content

Commit

Permalink
Merge 1e539ab into 7903f38
Browse files Browse the repository at this point in the history
  • Loading branch information
jerub committed Feb 14, 2019
2 parents 7903f38 + 1e539ab commit 35704d5
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions yapf/yapflib/format_token.py
Expand Up @@ -342,18 +342,14 @@ def is_string(self):
@property
@py3compat.lru_cache()
def is_multiline_string(self):
"""A multiline string."""
if py3compat.PY3:
prefix = '('
prefix += 'r|u|R|U|f|F|fr|Fr|fR|FR|rf|rF|Rf|RF' # strings
prefix += '|b|B|br|Br|bR|BR|rb|rB|Rb|RB' # bytes
prefix += ')?'
else:
prefix = '[uUbB]?[rR]?'
"""Test if this string is a multiline string.
regex = r'^{prefix}(?P<delim>"""|\'\'\').*(?P=delim)$'.format(prefix=prefix)
return (self.is_string and
re.match(regex, self.value, re.DOTALL) is not None)
Returns:
A multiline string always ends with triple quotes, so if it is a string
token, inspect the last 3 characters and return True if it is a triple
double or triple single quote mark.
"""
return self.is_string and self.value.endswith(('"""', "'''"))

@property
@py3compat.lru_cache()
Expand Down

0 comments on commit 35704d5

Please sign in to comment.