Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lmstudio/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class BaseModel(Struct, omit_defaults=True, kw_only=True):
# Allows structured predictions using a `pydantic.BaseModel` inspired format,
# even in applications that don't otherwise depend on Pydantic

def __init_subclass__(cls, *args: Any, **kwds: Any) -> None:
# Eagerly populate annotations on Python 3.14+
# Workaround for https://github.com/lmstudio-ai/lmstudio-python/issues/153
cls.__annotations__
super().__init_subclass__()

@classmethod
def model_json_schema(cls) -> DictSchema:
"""Returns JSON Schema dict describing the format of this class."""
Expand Down Expand Up @@ -186,6 +192,12 @@ class LMStudioStruct(Generic[TWireFormat], Struct, omit_defaults=True, kw_only=T
# * Allow non-default fields after default fields
#

def __init_subclass__(cls, *args: Any, **kwds: Any) -> None:
# Eagerly populate annotations on Python 3.14+
# Workaround for https://github.com/lmstudio-ai/lmstudio-python/issues/153
cls.__annotations__
super().__init_subclass__(*args, **kwds)

# This is actually defined in msgspec.Struct,
# but is missing from the published type stubs:
# https://github.com/jcrist/msgspec/pull/813
Expand Down
3 changes: 0 additions & 3 deletions tests/support/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Common test support interfaces and expected value definitions."""

# Work around https://github.com/jcrist/msgspec/issues/847
from __future__ import annotations

import logging
import sys

Expand Down
3 changes: 0 additions & 3 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Test schema processing support."""

# Work around https://github.com/jcrist/msgspec/issues/847
from __future__ import annotations

from typing import Any, Type

import pytest
Expand Down
Loading