From dc2b73adcc3abb1989b6651c1899d0e8e0abe759 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Thu, 2 Mar 2023 17:47:08 -0500 Subject: [PATCH] Fix separator regex to work on Windows --- core/dbt/clients/yaml_helper.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/dbt/clients/yaml_helper.py b/core/dbt/clients/yaml_helper.py index 293af5de191..0c9b87b0753 100644 --- a/core/dbt/clients/yaml_helper.py +++ b/core/dbt/clients/yaml_helper.py @@ -10,7 +10,7 @@ from yaml import Loader, SafeLoader, Dumper # type: ignore # noqa: F401 FRONTMATTER_CHECK = ["---\n", "---\r\n"] -FRONTMATTER_DELIMITER = re.compile(r"^---$", re.MULTILINE) +FRONTMATTER_DELIMITER = re.compile(r"^---", re.MULTILINE) NON_WHITESPACE = re.compile(r"\S") YAML_ERROR_MESSAGE = """ @@ -103,7 +103,4 @@ def parse_yaml_frontmatter(frontmatter_content: str, original_content: str): def has_yaml_frontmatter(content: str) -> bool: """Check first line for yaml frontmatter""" - # The following didn't work on Windows - # return content.startswith(FRONTMATTER_CHECK[0]) or content.startswith(FRONTMATTER_CHECK[1]) - # This seems a bit loose of a check, but the split function should take care of some of it - return FRONTMATTER_CHECK[0] in content or FRONTMATTER_CHECK[1] in content + return content.startswith(FRONTMATTER_CHECK[0]) or content.startswith(FRONTMATTER_CHECK[1])