Skip to content

Conversation

@jsklan
Copy link
Contributor

@jsklan jsklan commented Jan 26, 2026

Description

Fixes a bug where pydantic-core was unconditionally added as a dependency to all generated Python SDKs, breaking compatibility for users who want to use Pydantic v1.

Link to Devin run: https://app.devin.ai/sessions/28614b85508c4423a875ee8848ab1fca
Requested by: @jsklan

Changes Made

  • Modified the SDK, Pydantic model, and FastAPI generators to only add pydantic-core as a dependency when the Pydantic version is explicitly set to v2
  • For "both" mode, pydantic-core is a transitive dependency of pydantic>=2.0 and doesn't need to be explicitly listed
  • For v1 mode, pydantic-core doesn't exist
  • For v1_on_v2 mode, we use the pydantic.v1 compatibility layer
  • Added version 4.50.1 changelog entry

Updates since last revision

Fixed mypy type-checking errors that occurred because mypy tries to resolve imports at type-checking time even when they're inside runtime conditionals:

  • Added # type: ignore[import-not-found] comments to all pydantic_core imports in the core utilities
  • Made the top-level PydanticUndefined import in unchecked_base_model.py conditional with a None fallback for non-v2 mode

Testing

  • Pre-commit hooks pass
  • Seed tests pass in CI

Human Review Checklist

  • Verify the conditional check uses the correct variable name in each file (self._version in SDK vs self._pydantic_compatibility in others)
  • Confirm the PydanticUndefined = None fallback in unchecked_base_model.py is safe (it's only used inside if IS_PYDANTIC_V2: blocks)
  • Verify seed tests pass for Python SDK fixtures with different Pydantic version configurations

Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

…ix mypy errors

Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants