Skip to content

Commit 6bcdd3f

Browse files
I guess it's always a string in the comprehension, actually
1 parent 6feee3c commit 6bcdd3f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

mypy/fastparse.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,12 @@ def p() -> AST:
159159
p() # Call to assure syntactic validity (will throw an exception otherwise, exiting this function).
160160
if isinstance(source, str):
161161
tokens = tokenize.generate_tokens(io.StringIO(source).readline)
162-
to_find, to_replace = r"#\s*mypy:\s*ignore(?![-_])", "# type: ignore"
163-
source = tokenize.untokenize(
164-
(t, re.sub(to_find, to_replace, s) if t == tokenize.COMMENT else s)
165-
for t, s, *_ in tokens
166-
)
167162
else:
168163
tokens = tokenize.tokenize(io.BytesIO(source).readline)
169-
to_find_bytes, to_replace_bytes = rb"#\s*mypy:\s*ignore(?![-_])", b"# type: ignore"
170-
source = tokenize.untokenize(
171-
(t, re.sub(to_find_bytes, to_replace_bytes, s) if t == tokenize.COMMENT else s)
164+
source = tokenize.untokenize(
165+
(t, re.sub(r"#\s*mypy:\s*ignore(?![-_])", "# type: ignore", s) if t == tokenize.COMMENT else s)
172166
for t, s, *_ in tokens
173-
)
167+
)
174168
return p()
175169

176170

0 commit comments

Comments
 (0)