From aac25779ca06aa7ae0ceac2b4a19f69509eee49c Mon Sep 17 00:00:00 2001 From: Alexander Sokol Date: Mon, 21 Oct 2024 01:57:10 -0400 Subject: [PATCH] Check for the short_name parameter being None in Schema.get_type_by_short_name. --- cl/runtime/schema/schema.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cl/runtime/schema/schema.py b/cl/runtime/schema/schema.py index 1ea5fed3..949d9bda 100644 --- a/cl/runtime/schema/schema.py +++ b/cl/runtime/schema/schema.py @@ -29,6 +29,7 @@ from memoization import cached from typing_extensions import Self from cl.runtime.primitive.case_util import CaseUtil +from cl.runtime.primitive.string_util import StringUtil from cl.runtime.records.class_info import ClassInfo from cl.runtime.records.protocols import KeyProtocol from cl.runtime.schema.type_decl import TypeDecl @@ -71,6 +72,8 @@ def add_types_to_dict_by_short_name(cls, types: Iterable[Type]) -> None: @classmethod def get_type_by_short_name(cls, short_name: str) -> Type: """Get type from short name (class name with optional package alias).""" + if StringUtil.is_empty(short_name): + raise RuntimeError("Empty short name is passed to Schema.get_type_by_short_name.") # Get dictionary of types indexed by alias type_dict_by_short_name = cls.get_type_dict()