Skip to content

fix(pydantic): allow pydantic>=2 to be installed alongside v1 #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Literal, Optional, Sequence, Tuple, Union
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union

try:
from pydantic import UUID4, BaseModel, BaseSettings, Extra, Field
except ImportError:
from pydantic.v1 import UUID4, BaseModel, BaseSettings, Extra, Field

from pydantic import UUID4, BaseModel, BaseSettings, Extra, Field
from typing_extensions import Self


Expand Down Expand Up @@ -1603,9 +1607,8 @@ class RealtimeSessionOpened(BaseModel):
Once a real-time session is opened, the client will receive this message
"""

message_type: Literal[
RealtimeMessageTypes.session_begins
] = RealtimeMessageTypes.session_begins
message_type: RealtimeMessageTypes = RealtimeMessageTypes.session_begins


session_id: UUID4
"Unique identifier for the established session."
Expand Down Expand Up @@ -1637,9 +1640,7 @@ class RealtimeTranscript(BaseModel):
Base class for real-time transcript messages.
"""

message_type: Literal[
RealtimeMessageTypes.partial_transcript, RealtimeMessageTypes.final_transcript
]
message_type: RealtimeMessageTypes
"Describes the type of message"

audio_start: int
Expand Down Expand Up @@ -1670,9 +1671,7 @@ class RealtimePartialTranscript(RealtimeTranscript):
As you send audio data to the service, the service will immediately start responding with partial transcripts.
"""

message_type: Literal[
RealtimeMessageTypes.partial_transcript
] = RealtimeMessageTypes.partial_transcript
message_type: RealtimeMessageTypes = RealtimeMessageTypes.partial_transcript


class RealtimeFinalTranscript(RealtimeTranscript):
Expand All @@ -1682,9 +1681,7 @@ class RealtimeFinalTranscript(RealtimeTranscript):
sent to you so far with higher accuracy, as well as add punctuation and casing to the transcription text.
"""

message_type: Literal[
RealtimeMessageTypes.final_transcript
] = RealtimeMessageTypes.final_transcript
message_type: RealtimeMessageTypes = RealtimeMessageTypes.final_transcript

punctuated: bool
"Whether the transcript has been punctuated and cased"
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

setup(
name="assemblyai",
version="0.12.0",
version="0.13.0",
description="AssemblyAI Python SDK",
author="AssemblyAI",
author_email="[email protected]",
packages=find_packages(),
install_requires=[
"httpx>=0.19.0",
"pydantic>=1.7.0",
"typing-extensions>=3.7,<4.6",
"pydantic>=1.7.0,!=1.10.7",
"typing-extensions>=3.7",
"websockets>=11.0",
],
extras_require={
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{38,39,310,311}-websockets{latest,11.0}-pyaudio{latest,0.2}-httpx{latest,0.24,0.23,0.22,0.21}-pydantic{latest,1.10,1.9,1.8,1.7}-typing-extensions
envlist = py{38,39,310,311}-websockets{latest,11.0}-pyaudio{latest,0.2}-httpx{latest,0.24,0.23,0.22,0.21}-pydantic{latest,2,1.10,1.9,1.8,1.7}-typing-extensions

[testenv]
deps =
Expand All @@ -12,11 +12,12 @@ deps =
httpx0.22: httpx>=0.22.0,<0.23.0
httpx0.21: httpx>=0.21.0,<0.22.0
pydanticlatest: pydantic
pydantic1.10: pydantic>=1.10.0,<1.11.0
pydantic2: pydantic>=2
pydantic1.10: pydantic>=1.10.0,<1.11.0,!=1.10.7
pydantic1.9: pydantic>=1.9.0,<1.10.0
pydantic1.8: pydantic>=1.8.0,<1.9.0
pydantic1.7: pydantic>=1.7.0,<1.8.0
typing-extensions: typing-extensions>=3.7,<4.6
typing-extensions: typing-extensions>=3.7
# extra dependencies
pyaudiolatest: pyaudio
pyaudio0.2: pyaudio>=0.2.13,<0.3.0
Expand Down