Skip to content

Commit dbe89a6

Browse files
Update fastparse.py: exclude start of line
1 parent a86b946 commit dbe89a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def ast3_parse(
139139
source: str, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
140140
) -> AST:
141141
# Hack to support "mypy: ignore" comments until the builtin compile function changes to allow us to detect it otherwise:
142-
source = re.sub(r"#\s*mypy:\s*ignore", "# type: ignore", source)
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)
143144
return ast3.parse(
144145
source,
145146
filename,

0 commit comments

Comments
 (0)