Skip to content

Python SDK incompatible with Python 3.14+ due to Pydantic V1 compatibility layer #10004

@nopcoder

Description

@nopcoder

Description

The Python SDK (lakefs-sdk) emits a warning when used with Python 3.14 due to incompatibility between the Pydantic V1 compatibility layer and Python 3.14. While the import currently succeeds, the warning indicates that core Pydantic V1 functionality may not work correctly.

Warning Message

/Users/barak/work/lakeFS/.venv/lib/python3.14/site-packages/lakefs_sdk/api/actions_api.py:21: UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.
  from pydantic.v1 import validate_arguments, ValidationError

Root Cause

The SDK is generated using OpenAPI Generator v7.0.1 (treeverse/openapi-generator-cli:v7.0.1.4), which produces Pydantic V1 code. A post-processing script (clients/python-static/pydantic.sh) wraps all pydantic imports with a try/except pattern:

try:
    from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
    from pydantic import validate_arguments, ValidationError

This was intended to support both Pydantic V1 and V2 users. However, pydantic.v1 (the compatibility shim in Pydantic V2) relies on Python internals that were removed in Python 3.14, making it potentially unreliable.

Affected features include:

  • validate_arguments decorator (used in all 19 API files)
  • V1-style constrained types (conint, constr, conlist)
  • V1-style validators (@validator)

Environment

  • Python version: 3.14
  • lakefs-sdk version: current
  • Pydantic version: 2.x (with degraded pydantic.v1 shim on Python 3.14)

Proposed Solution

  1. Upgrade OpenAPI Generator from v7.0.1 to v7.2.0+

    • Starting with v7.1.0, the default python generator produces native Pydantic V2 code
    • A separate python-pydantic-v1 generator exists for backwards compatibility
  2. Remove the pydantic.sh post-processing script

    • No longer needed when generating native Pydantic V2 code
  3. Update dependency constraints

    • Change pydantic = "^1.10.5, <2" to pydantic >= 2.0 in pyproject.toml
    • Update setup.py accordingly

Files to Modify

  • Makefile - Update OPENAPI_GENERATOR_IMAGE and remove PYTHON_POST_PROCESS_FILE
  • clients/python-static/pydantic.sh - Remove or archive
  • clients/python/pyproject.toml - Will be regenerated with correct pydantic constraint
  • clients/python/setup.py - Will be regenerated with correct pydantic constraint

Impact

  • Breaking change for users on Pydantic V1 (they would need to upgrade to Pydantic V2)
  • Enables support for Python 3.14+
  • Aligns SDK with modern Pydantic ecosystem

References

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions