Skip to content

Commit

Permalink
Merge pull request #45 from bjhargrave/yamllint-no-line-length
Browse files Browse the repository at this point in the history
lint: Disable line length lint check
  • Loading branch information
bjhargrave authored Aug 22, 2024
2 parents 139a429 + fe98bf0 commit a049a4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/instructlab/schema/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
DEFAULT_TAXONOMY_FOLDERS: list[str] = ["compositional_skills", "knowledge"]
"""Taxonomy folders which are also the schema names"""

DEFAULT_YAMLLINT_CONFIG: str = "{extends: relaxed, rules: {line-length: {max: 120}}}"
DEFAULT_YAMLLINT_CONFIG: str = "{extends: relaxed, rules: {line-length: disable}}"
"""Default yamllint configuration"""


Expand Down
26 changes: 12 additions & 14 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ def test_invalid(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path)
parser = TaxonomyParser(schema_version=0, message_format=TaxonomyMessageFormat.LOGGING)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_greater_than_or_equal_to(1)
assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_greater_than_or_equal_to(2)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
assert_that(caplog.records).extracting(
"message",
filter=self.message_filter(f"{re.escape(test_yaml)}:"),
).is_length(len(caplog.records))
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"line too long"),
).contains_only(logging.WARNING)
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"Unevaluated properties.*createdby"),
Expand All @@ -47,9 +43,15 @@ def test_invalid(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path)
).contains_only(logging.ERROR)

def test_invalid_yamlint_strict(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
yamllint_config = "{extends: relaxed, rules: {line-length: {max: 120}}}"
test_yaml = "compositional_skills/invalid_yaml/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
parser = TaxonomyParser(schema_version=0, yamllint_strict=True, message_format=TaxonomyMessageFormat.LOGGING)
parser = TaxonomyParser(
schema_version=0,
message_format=TaxonomyMessageFormat.LOGGING,
yamllint_config=yamllint_config,
yamllint_strict=True,
)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_zero()
Expand Down Expand Up @@ -295,7 +297,7 @@ def test_version_1_as_version_2(self, caplog: pytest.LogCaptureFixture, testdata
parser = TaxonomyParser(schema_version=2, message_format=TaxonomyMessageFormat.LOGGING)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_greater_than_or_equal_to(1)
assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_greater_than_or_equal_to(1)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
Expand All @@ -304,10 +306,6 @@ def test_version_1_as_version_2(self, caplog: pytest.LogCaptureFixture, testdata
"message",
filter=self.message_filter(f"{re.escape(test_yaml)}:"),
).is_length(len(caplog.records))
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"line too long"),
).contains_only(logging.WARNING)
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"version.*required property"),
Expand All @@ -321,7 +319,7 @@ def test_format_github(self, capsys: pytest.CaptureFixture[str], testdata: pathl
parser = TaxonomyParser(schema_version=0, message_format=TaxonomyMessageFormat.GITHUB)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_greater_than_or_equal_to(1)
assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_greater_than_or_equal_to(2)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
Expand All @@ -340,7 +338,7 @@ def test_format_standard(self, capsys: pytest.CaptureFixture[str], testdata: pat
parser = TaxonomyParser(schema_version=0, message_format=TaxonomyMessageFormat.STANDARD)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_greater_than_or_equal_to(1)
assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_greater_than_or_equal_to(2)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
Expand All @@ -359,7 +357,7 @@ def test_format_auto(self, capsys: pytest.CaptureFixture[str], testdata: pathlib
parser = TaxonomyParser(schema_version=0)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_greater_than_or_equal_to(1)
assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_greater_than_or_equal_to(2)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
Expand Down

0 comments on commit a049a4d

Please sign in to comment.