Blob Blame History Raw
From 84937582b81d570b95354e33a746947f84462c55 Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Mon, 12 Jun 2023 21:28:57 -0400
Subject: [PATCH] add fix for muting FSTRING_MIDDLE in 3.12+

---
 pycodestyle.py        | 5 +++++
 testsuite/python36.py | 2 ++
 2 files changed, 7 insertions(+)
 create mode 100644 testsuite/python36.py

diff --git a/pycodestyle.py b/pycodestyle.py
index f5e05cf..4a97372 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -2010,6 +2010,11 @@ class Checker:
                 continue
             if token_type == tokenize.STRING:
                 text = mute_string(text)
+            elif (
+                    sys.version_info >= (3, 12) and
+                    token_type == tokenize.FSTRING_MIDDLE
+            ):
+                text = 'x' * len(text)
             if prev_row:
                 (start_row, start_col) = start
                 if prev_row != start_row:    # different row
diff --git a/testsuite/python36.py b/testsuite/python36.py
new file mode 100644
index 0000000..94ec2dc
--- /dev/null
+++ b/testsuite/python36.py
@@ -0,0 +1,2 @@
+#: Okay
+f'{hello}:{world}'
-- 
2.41.0