From cfb674dffdff1ef52e8a07849567a3277eb1ff88 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 3 Dec 2025 14:29:42 -0500 Subject: [PATCH] fix: Add Python 3.14+ compatibility with Pydantic V2 Fixes incompatibility with Python 3.14+ where Pydantic V1's compatibility layer (pydantic.v1) is not supported. Changes: - Update setup.py to require Pydantic V2 and pydantic-settings for Python 3.14+ - Add Python 3.12, 3.13, 3.14 to supported version classifiers - Enhance import logic in types.py to raise clear error message when Pydantic V2 is not available on Python 3.14+ - Maintain backward compatibility with Python 3.8-3.13 supporting both Pydantic V1 and V2 The SDK now properly uses Pydantic V2 natively on Python 3.14+ while preserving existing behavior on earlier Python versions. --- assemblyai/types.py | 10 +++++++++- setup.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/assemblyai/types.py b/assemblyai/types.py index e2fa01e..536525a 100644 --- a/assemblyai/types.py +++ b/assemblyai/types.py @@ -1,3 +1,4 @@ +import sys from datetime import datetime from enum import Enum, EnumMeta from typing import ( @@ -24,7 +25,14 @@ pydantic_v2 = True except ImportError: - # pydantic v1 import + # Python 3.14+ requires Pydantic V2 + if sys.version_info >= (3, 14): + raise ImportError( + "Python 3.14 or greater requires Pydantic V2 and pydantic-settings. " + "Please install with: pip install 'pydantic>=2.0' 'pydantic-settings>=2.0'" + ) from None + + # pydantic v1 import (fallback for Python < 3.14) from pydantic.v1 import UUID4, BaseModel, BaseSettings, ConfigDict, Field, validator pydantic_v2 = False diff --git a/setup.py b/setup.py index 8e7e05d..6657b90 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,9 @@ def get_version() -> str: packages=find_packages(exclude=["tests", "tests.*"]), install_requires=[ "httpx>=0.19.0", - "pydantic>=1.10.17", + "pydantic>=2.0; python_version>='3.14'", + "pydantic>=1.10.17; python_version<'3.14'", + "pydantic-settings>=2.0; python_version>='3.14'", "typing-extensions>=3.7", "websockets>=11.0", ], @@ -42,6 +44,9 @@ def get_version() -> str: "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ], long_description=long_description, long_description_content_type="text/markdown",