Skip to content

Commit af86125

Browse files
Use re.sub instead of str.replace, so as to match type ignore behavior better.
1 parent 652044c commit af86125

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
def ast3_parse(
139139
source: str | bytes, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
140140
) -> AST:
141-
source = source.replace("# mypy: ignore", "# type: ignore") # hack to support "mypy: ignore" comments until the in-built compile function changes to allow us to detect it otherwise.
141+
source = re.sub(r"#\s*mypy:\s*ignore", "# type: ignore", source) # hack to support "mypy: ignore" comments until the in-built compile function changes to allow us to detect it otherwise.
142142
return ast3.parse(
143143
source,
144144
filename,

0 commit comments

Comments
 (0)