diff --git a/dev_tools/check_useless_exclude_paths_hooks.py b/dev_tools/check_useless_exclude_paths_hooks.py index 4fec637..a6688f9 100644 --- a/dev_tools/check_useless_exclude_paths_hooks.py +++ b/dev_tools/check_useless_exclude_paths_hooks.py @@ -72,6 +72,7 @@ def extract_literal_exclude_paths(exclude_regex: str) -> list[str]: .replace(" ", "") .replace("(?x)^(", "") .replace("^", "") + .replace(r"\.", ".") .replace(")", "") .split("|") ) diff --git a/tests/test_check_useless_exclude_paths_hooks.py b/tests/test_check_useless_exclude_paths_hooks.py index 4bcf73e..090ee5c 100644 --- a/tests/test_check_useless_exclude_paths_hooks.py +++ b/tests/test_check_useless_exclude_paths_hooks.py @@ -47,6 +47,10 @@ def test_extract_literal_exclude_paths_for_regex_only_exclude_should_return_empt assert extract_literal_exclude_paths(r"(?x)^(bar/.*\.png|.*\.lock$)") == [] +def test_extract_literal_exclude_paths_for_escaped_dot_should_unescape() -> None: + assert extract_literal_exclude_paths(r"(?x)^(foo/bar\.py)") == ["foo/bar.py"] + + def test_extract_literal_exclude_paths_for_single_literal_should_return_path() -> None: assert extract_literal_exclude_paths("packages/thirdparty/") == ["packages/thirdparty/"]