Skip to content
Snippets Groups Projects

Resolve "front-matter linter"

Merged Remi PLANEL requested to merge front-matter-linter into main
@@ -2,7 +2,7 @@ import typer
from typing_extensions import Annotated
from typing import Optional, List
from pathlib import Path
from pydantic import BaseModel
from pydantic import BaseModel, ValidationError
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter
from enum import Enum
@@ -54,6 +54,12 @@ def lint(
with open(file) as f:
metadata, _ = frontmatter.parse(f.read())
# print(metadata)
FrontMatter.model_validate(metadata)
# print(val)
try:
FrontMatter.model_validate(metadata)
except ValidationError as exc:
# print(repr(exc.errors()[0]["type"]))
# print(repr(exc))
# print(exc.errors())
for err in exc.errors():
print(f"{err['msg']} : {err['type']} {err['loc']}")