Skip to content

Commit 7831c70

Browse files
Update fastparse.py: exclude start of line
1 parent af86125 commit 7831c70

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mypy/fastparse.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@
138138
def ast3_parse(
139139
source: str | bytes, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
140140
) -> AST:
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.
141+
# Hack to support "mypy: ignore" comments until the builtin compile function changes to allow us to detect it otherwise:
142+
# (does not apply at the start of the line to avoid conflicting with mypy file configuration comments https://mypy.readthedocs.io/en/stable/inline_config.html ; see also, util.get_mypy_comments in this codebase)
143+
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore", "# type: ignore", source)
142144
return ast3.parse(
143145
source,
144146
filename,

0 commit comments

Comments
 (0)