Skip to content

Commit 065b007

Browse files
committed
convince mypy this is always a string
1 parent 2cc9b86 commit 065b007

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyupgrade/_plugins/percent_format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _fix_percent_format_dict(
195195
elif k.value in KEYWORDS:
196196
return
197197
seen_keys.add(k.value)
198-
keys[ast_to_offset(k)] = k
198+
keys[ast_to_offset(k)] = k.value
199199

200200
# TODO: this is overly timid
201201
brace = i + 4
@@ -211,13 +211,13 @@ def _fix_percent_format_dict(
211211
if key is None:
212212
continue
213213
# we found the key, but the string didn't match (implicit join?)
214-
elif ast.literal_eval(token.src) != key.value:
214+
elif ast.literal_eval(token.src) != key:
215215
return
216216
# the map uses some strange syntax that's not `'key': value`
217217
elif tokens[j + 1].src != ':' or tokens[j + 2].src != ' ':
218218
return
219219
else:
220-
key_indices.append((j, key.value))
220+
key_indices.append((j, key))
221221
assert not keys, keys
222222

223223
tokens[brace_end] = tokens[brace_end]._replace(src=')')

0 commit comments

Comments
 (0)