From c24ac7b9c08fddc62c59b529d23b4a07bb6ee4e1 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Sat, 1 Feb 2025 16:34:28 +0100 Subject: [PATCH] Cleanup json schema validation (#819) --- src/poetry/core/json/__init__.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/poetry/core/json/__init__.py b/src/poetry/core/json/__init__.py index 827956563..cd78e1f0b 100644 --- a/src/poetry/core/json/__init__.py +++ b/src/poetry/core/json/__init__.py @@ -3,8 +3,6 @@ import json from importlib.resources import files -from pathlib import Path -from typing import TYPE_CHECKING from typing import Any import fastjsonschema @@ -12,23 +10,12 @@ 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.")