-
Notifications
You must be signed in to change notification settings - Fork 434
Description
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, ValidationErrorThis 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_argumentsdecorator (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.v1shim on Python 3.14)
Proposed Solution
-
Upgrade OpenAPI Generator from v7.0.1 to v7.2.0+
- Starting with v7.1.0, the default
pythongenerator produces native Pydantic V2 code - A separate
python-pydantic-v1generator exists for backwards compatibility
- Starting with v7.1.0, the default
-
Remove the
pydantic.shpost-processing script- No longer needed when generating native Pydantic V2 code
-
Update dependency constraints
- Change
pydantic = "^1.10.5, <2"topydantic >= 2.0inpyproject.toml - Update
setup.pyaccordingly
- Change
Files to Modify
Makefile- UpdateOPENAPI_GENERATOR_IMAGEand removePYTHON_POST_PROCESS_FILEclients/python-static/pydantic.sh- Remove or archiveclients/python/pyproject.toml- Will be regenerated with correct pydantic constraintclients/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
- [BUG] Python-pydantic-v1 is in the generator list, but python-pydantic-v1 is not in openapi-generator-cli 7.0.1 OpenAPITools/openapi-generator#16888 (python-pydantic-v1 availability)
- [PYTHON] update to pydantic v2 OpenAPITools/openapi-generator#16468 (pydantic v2 migration request)