Skip to content

Commit 3131455

Browse files
committed
Only try using debug specifier if the f-string doesn't have many components
1 parent 104e967 commit 3131455

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/python_minifier/f_string.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ def candidates(self):
4949
if is_ast_node(v, ast.Str):
5050

5151
# Could this be used as a debug specifier?
52-
debug_specifier = re.match(r'.*=\s*$', v.s)
53-
if debug_specifier:
54-
# Maybe!
55-
try:
56-
debug_specifier_candidates = [x + '{' + v.s + '}' for x in candidates]
57-
except Exception as e:
58-
continue
52+
if len(candidates) < 10:
53+
debug_specifier = re.match(r'.*=\s*$', v.s)
54+
if debug_specifier:
55+
# Maybe!
56+
try:
57+
debug_specifier_candidates = [x + '{' + v.s + '}' for x in candidates]
58+
except Exception as e:
59+
continue
5960

6061
try:
6162
candidates = [x + self.str_for(v.s, quote) for x in candidates]

0 commit comments

Comments
 (0)