Skip to content

Commit

Permalink
Fix enum type resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
KaQuMiQ authored Sep 5, 2024
1 parent 3e053bd commit d150cc1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "draive"
description = "Framework designed to simplify and accelerate the development of LLM-based applications."
version = "0.28.4"
version = "0.28.5"
readme = "README.md"
maintainers = [
{ name = "Kacper Kaliński", email = "[email protected]" },
Expand Down
4 changes: 2 additions & 2 deletions src/draive/parameters/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ def parameter_specification( # noqa: C901, PLR0912, PLR0915, PLR0911, PLR0913
raise TypeError("Unsupported literal type annotation: %s", annotation)

case enum_type if isinstance(enum_type, enum.EnumType):
if isinstance(enum_type, enum.StrEnum):
if issubclass(enum_type, enum.StrEnum):
specification = {
"type": "string",
"enum": list(enum_type),
}

elif isinstance(enum_type, enum.IntEnum):
elif issubclass(enum_type, enum.IntEnum):
specification = {
"type": "integer",
"enum": list(enum_type),
Expand Down
4 changes: 2 additions & 2 deletions src/draive/parameters/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,10 @@ def parameter_validator[Value]( # noqa: C901, PLR0915, PLR0912, PLR0913
validator = _prepare_any_enum_validator(resolved_args)

case enum_type if isinstance(enum_type, enum.EnumType):
if isinstance(enum_type, enum.StrEnum):
if issubclass(enum_type, enum.StrEnum):
validator = _prepare_str_enum_validator(resolved_args)

elif isinstance(enum_type, enum.IntEnum):
elif issubclass(enum_type, enum.IntEnum):
validator = _prepare_int_enum_validator(resolved_args)

else:
Expand Down

0 comments on commit d150cc1

Please sign in to comment.