Skip to content

Commit cfb674d

Browse files
committed
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.
1 parent d7893e2 commit cfb674d

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

assemblyai/types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from datetime import datetime
23
from enum import Enum, EnumMeta
34
from typing import (
@@ -24,7 +25,14 @@
2425

2526
pydantic_v2 = True
2627
except ImportError:
27-
# pydantic v1 import
28+
# Python 3.14+ requires Pydantic V2
29+
if sys.version_info >= (3, 14):
30+
raise ImportError(
31+
"Python 3.14 or greater requires Pydantic V2 and pydantic-settings. "
32+
"Please install with: pip install 'pydantic>=2.0' 'pydantic-settings>=2.0'"
33+
) from None
34+
35+
# pydantic v1 import (fallback for Python < 3.14)
2836
from pydantic.v1 import UUID4, BaseModel, BaseSettings, ConfigDict, Field, validator
2937

3038
pydantic_v2 = False

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def get_version() -> str:
2121
packages=find_packages(exclude=["tests", "tests.*"]),
2222
install_requires=[
2323
"httpx>=0.19.0",
24-
"pydantic>=1.10.17",
24+
"pydantic>=2.0; python_version>='3.14'",
25+
"pydantic>=1.10.17; python_version<'3.14'",
26+
"pydantic-settings>=2.0; python_version>='3.14'",
2527
"typing-extensions>=3.7",
2628
"websockets>=11.0",
2729
],
@@ -42,6 +44,9 @@ def get_version() -> str:
4244
"Programming Language :: Python :: 3.9",
4345
"Programming Language :: Python :: 3.10",
4446
"Programming Language :: Python :: 3.11",
47+
"Programming Language :: Python :: 3.12",
48+
"Programming Language :: Python :: 3.13",
49+
"Programming Language :: Python :: 3.14",
4550
],
4651
long_description=long_description,
4752
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)