Skip to content

Commit

Permalink
Fix separator regex to work on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Mar 3, 2023
1 parent 04e2767 commit dc2b73a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/dbt/clients/yaml_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -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])

0 comments on commit dc2b73a

Please sign in to comment.