github koxudaxi/datamodel-code-generator 0.66.0

6 hours ago

Breaking Changes

  • msgspec nullable annotated fields now place None outside Annotated - For msgspec.Struct models, nullable fields that carry Meta/Annotated constraints no longer wrap the type in Optional inside the Annotated[...]. The None member is now emitted as a separate union arm outside the Annotated wrapper, which changes the generated type hints and the resulting imports (Optional is dropped when no longer needed). This is required for the generated models to validate correctly at runtime under msgspec, but it changes output for existing users. (#3495)
# Before
from typing import Annotated, Optional, Union
name: Union[Annotated[Optional[str], Meta(max_length=5)], UnsetType] = UNSET

# After
from typing import Annotated, Union
name: Union[Annotated[str, Meta(max_length=5)], None, UnsetType] = UNSET

What's Changed

Full Changelog: 0.65.1...0.66.0

Don't miss a new datamodel-code-generator release

NewReleases is sending notifications on new releases.