From 2983d4478fa03dbbd495ff30e86320537b9dd0a1 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 10 Feb 2015 08:14:53 -0800 Subject: [PATCH] Use the tokenizer for great success --- pre_commit_hooks/string_fixer.py | 52 +++++++++++++++------ tests/string_fixer_test.py | 78 ++++++++++---------------------- 2 files changed, 63 insertions(+), 67 deletions(-) diff --git a/pre_commit_hooks/string_fixer.py b/pre_commit_hooks/string_fixer.py index 9d2213a..9ef7a37 100644 --- a/pre_commit_hooks/string_fixer.py +++ b/pre_commit_hooks/string_fixer.py @@ -3,34 +3,60 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import re +import io import tokenize double_quote_starts = tuple(s for s in tokenize.single_quoted if '"' in s) -compiled_tokenize_string = re.compile('(?