Method: pylint.checkers.strings._get_quote_delimiter
Calls: 47, Exceptions: 0, Paths: 1Back
Path 1: 47 calls (1.0)
'"double-quoted string"' (8) "'single-quoted string'" (8) '"another double-quoted string"' (4) '"yet another double-quoted string"' (4) "'another sing...
'"' (25) "'" (22)
1def _get_quote_delimiter(string_token: str) -> str:
2 """Returns the quote character used to delimit this token string.
3
4 This function checks whether the token is a well-formed string.
5
6 Args:
7 string_token: The token to be parsed.
8
9 Returns:
10 A string containing solely the first quote delimiter character in the
11 given string.
12
13 Raises:
14 ValueError: No quote delimiter characters are present.
15 """
16 match = QUOTE_DELIMITER_REGEX.match(string_token)
17 if not match:
18 raise ValueError(f"string token {string_token} is not a well-formed string")
19 return match.group(2)