We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent afcce08 commit fb9f503Copy full SHA for fb9f503
pyupgrade/_main.py
@@ -276,6 +276,10 @@ def _fix_encode_to_binary(tokens: list[Token], i: int) -> None:
276
del tokens[victims]
277
278
279
+# copied from 3.15 @ 0ac890bea7
280
+_cookie_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
281
+
282
283
def _fix_tokens(contents_text: str) -> str:
284
try:
285
tokens = src_to_tokens(contents_text)
@@ -294,7 +298,7 @@ def _fix_tokens(contents_text: str) -> str:
294
298
token.utf8_byte_offset == 0 and
295
299
token.line < 3 and
296
300
token.name == 'COMMENT' and
297
- tokenize.cookie_re.match(token.src)
301
+ _cookie_re.match(token.src)
302
):
303
del tokens[i]
304
assert tokens[i].name == 'NL', tokens[i].name
0 commit comments