Skip to content

Commit

Permalink
Cleanup json schema validation (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus authored Feb 1, 2025
1 parent f4f327c commit c24ac7b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/poetry/core/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,19 @@
import json

from importlib.resources import files
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any

import fastjsonschema

from fastjsonschema.exceptions import JsonSchemaException


if TYPE_CHECKING:
from importlib.abc import Traversable


SCHEMA_DIR = Path(__file__).parent / "schemas"


def _get_schema_file(schema_name: str) -> Traversable:
return files(__package__) / "schemas" / f"{schema_name}.json"


class ValidationError(ValueError):
pass


def validate_object(obj: dict[str, Any], schema_name: str) -> list[str]:
schema_file = _get_schema_file(schema_name)
schema_file = files(__package__) / "schemas" / f"{schema_name}.json"

if not schema_file.is_file():
raise ValueError(f"Schema {schema_name} does not exist.")
Expand Down

0 comments on commit c24ac7b

Please sign in to comment.