Skip to content

Commit d697114

Browse files
use a (?![-_]) to further ignore inline-configs
1 parent 44242fb commit d697114

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def ast3_parse(
141141
# Hack to support "mypy: ignore" comments until the builtin compile function changes to allow us to detect it otherwise:
142142
# (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)
143143
if isinstance(source, str):
144-
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore", "# type: ignore", source)
144+
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore(?![-_])", "# type: ignore", source)
145145
else:
146-
source = re.sub(rb"(?<!^)#\s*mypy:\s*ignore", b"# type: ignore", source)
146+
source = re.sub(rb"(?<!^)#\s*mypy:\s*ignore(?![-_])", b"# type: ignore", source)
147147
return ast3.parse(
148148
source,
149149
filename,

0 commit comments

Comments
 (0)