Skip to content

Commit

Permalink
Update fastparse.py: exclude start of line
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattscarpenter authored Oct 4, 2024
1 parent a86b946 commit dbe89a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def ast3_parse(
source: str, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
) -> AST:
# Hack to support "mypy: ignore" comments until the builtin compile function changes to allow us to detect it otherwise:
source = re.sub(r"#\s*mypy:\s*ignore", "# type: ignore", source)
# (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)
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore", "# type: ignore", source)
return ast3.parse(
source,
filename,
Expand Down

0 comments on commit dbe89a6

Please sign in to comment.