Skip to content

[Compatibility Issue] litestar.contrib.pydantic removed in litestar 3.0 #1910

Description

@xyf5432

Affected File

src/evidently/utils/schema.py:17, 55

Current Code

from litestar.contrib.pydantic import PydanticSchemaPlugin

class PolymorphicPydanticSchemaPlugin(PydanticSchemaPlugin):
    """Changes all fields with PolymorphicModel base class types into a union of it's subtypes"""
    ...

Root Cause

litestar.contrib.pydantic was a deprecation-warning re-export shim that forwarded to litestar.plugins.pydantic. It was deprecated since litestar 2.12 and removed in litestar 3.0.0. Any import from litestar.contrib.pydantic now raises:

ModuleNotFoundError: No module named 'litestar.contrib.pydantic'

The replacement import path is litestar.plugins.pydantic.

Impact

  • Severity: High — runtime crash on litestar >= 3.0.0

Solution

# Before:
from litestar.contrib.pydantic import PydanticSchemaPlugin

# After:
try:
    from litestar.plugins.pydantic import PydanticSchemaPlugin
except ImportError:  # backward compatibility with older litestar
    from litestar.contrib.pydantic import PydanticSchemaPlugin

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions