Skip to content

Commit

Permalink
style(python/sdk): Fix linting in Python SDK (#2636)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 675799264e2de79f8c4259a16d3e859c668f571a
  • Loading branch information
ploeber authored and jhazenaai committed Nov 20, 2023
1 parent ae1db94 commit 0c8be06
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion assemblyai/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ def __init__(
client: _client.Client,
) -> None:
self._client = client
self._websocket: Optional[websockets_client.ClientConnection] = None
self._websocket: Optional[websockets.sync.client.ClientConnection] = None

self._on_open = on_open
self._on_data = on_data
Expand Down
8 changes: 4 additions & 4 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def auto_chapters(self, enable: Optional[bool]) -> None:
"Enable Auto Chapters."

# Validate required params are also set
if enable and self.punctuate == False:
if enable and self.punctuate is False:
raise ValueError(
"If `auto_chapters` is enabled, then `punctuate` must not be disabled"
)
Expand Down Expand Up @@ -1146,11 +1146,11 @@ def set_summarize(
return self

# Validate that required parameters are also set
if self._raw_transcription_config.punctuate == False:
if self._raw_transcription_config.punctuate is False:
raise ValueError(
"If `summarization` is enabled, then `punctuate` must not be disabled"
)
if self._raw_transcription_config.format_text == False:
if self._raw_transcription_config.format_text is False:
raise ValueError(
"If `summarization` is enabled, then `format_text` must not be disabled"
)
Expand Down Expand Up @@ -1666,7 +1666,7 @@ def __init__(
"""
from . import Transcript

if type(transcript) == str:
if isinstance(transcript, str):
transcript = Transcript(transcript_id=transcript)

super().__init__(transcript)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_auto_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_auto_chapters_enabled(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("auto_chapters") == True
assert request_body.get("auto_chapters") is True

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_auto_highlights.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_auto_highlights_enabled(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("auto_highlights") == True
assert request_body.get("auto_highlights") is True

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_content_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_content_safety_enabled(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("content_safety") == True
assert request_body.get("content_safety") is True

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_content_safety_with_confidence_threshold(httpx_mock: HTTPXMock):
),
)

assert request.get("content_safety") == True
assert request.get("content_safety") is True
assert request.get("content_safety_confidence") == confidence


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_entity_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_entity_detection_enabled(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("entity_detection") == True
assert request_body.get("entity_detection") is True

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_lemur.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_lemur_purge_request_data_fails(httpx_mock: HTTPXMock):
json=mock_lemur_purge_response,
)

with pytest.raises(aai.LemurError) as error:
with pytest.raises(aai.LemurError):
aai.Lemur.purge_request_data(mock_request_id)

assert len(httpx_mock.get_requests()) == 1
1 change: 0 additions & 1 deletion tests/unit/test_realtime_transcriber.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime
import json
import uuid
from typing import Optional
from unittest.mock import MagicMock
from urllib.parse import urlencode

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_sentiment_analysis_enabled(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("sentiment_analysis") == True
assert request_body.get("sentiment_analysis") is True

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/test_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import tests.unit.factories as factories
import tests.unit.unit_test_utils as test_utils
import assemblyai as aai
from tests.unit import factories

aai.settings.api_key = "test"

Expand Down Expand Up @@ -74,9 +73,9 @@ def test_default_summarization_params(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("summarization") == True
assert request_body.get("summary_model") == None
assert request_body.get("summary_type") == None
assert request_body.get("summarization") is True
assert request_body.get("summary_model") is None
assert request_body.get("summary_type") is None

# Check that transcript was properly parsed from JSON response
assert transcript.error is None
Expand Down Expand Up @@ -106,7 +105,7 @@ def test_summarization_with_params(httpx_mock: HTTPXMock):
)

# Check that request body was properly defined
assert request_body.get("summarization") == True
assert request_body.get("summarization") is True
assert request_body.get("summary_model") == summary_model
assert request_body.get("summary_type") == summary_type

Expand Down

0 comments on commit 0c8be06

Please sign in to comment.