

chore: auto-fix ruff errors
@36fcca48076d8984e2c1418d282fb406175fb61e
--- tests/api_model_test.py
+++ tests/api_model_test.py
... | ... | @@ -7,19 +7,19 @@ |
7 | 7 |
MIN_EXPECTED_NUMBER_OF_MODELS = 70 # At the time of the test creation there are 89 models |
8 | 8 |
|
9 | 9 |
|
10 |
-@pytest.mark.asyncio() |
|
10 |
+@pytest.mark.asyncio |
|
11 | 11 |
async def test_list_models(openai_client: AsyncOpenAI) -> None: |
12 | 12 |
models = (await openai_client.models.list()).data |
13 | 13 |
assert len(models) > MIN_EXPECTED_NUMBER_OF_MODELS |
14 | 14 |
|
15 | 15 |
|
16 |
-@pytest.mark.asyncio() |
|
16 |
+@pytest.mark.asyncio |
|
17 | 17 |
async def test_model_exists(openai_client: AsyncOpenAI) -> None: |
18 | 18 |
model = await openai_client.models.retrieve(MODEL_THAT_EXISTS) |
19 | 19 |
assert model.id == MODEL_THAT_EXISTS |
20 | 20 |
|
21 | 21 |
|
22 |
-@pytest.mark.asyncio() |
|
22 |
+@pytest.mark.asyncio |
|
23 | 23 |
async def test_model_does_not_exist(openai_client: AsyncOpenAI) -> None: |
24 | 24 |
with pytest.raises(openai.NotFoundError): |
25 | 25 |
await openai_client.models.retrieve(MODEL_THAT_DOES_NOT_EXIST) |
--- tests/api_timestamp_granularities_test.py
+++ tests/api_timestamp_granularities_test.py
... | ... | @@ -2,12 +2,13 @@ |
2 | 2 |
|
3 | 3 |
from pathlib import Path |
4 | 4 |
|
5 |
-from faster_whisper_server.api_models import TIMESTAMP_GRANULARITIES_COMBINATIONS, TimestampGranularities |
|
6 | 5 |
from openai import AsyncOpenAI |
7 | 6 |
import pytest |
8 | 7 |
|
8 |
+from faster_whisper_server.api_models import TIMESTAMP_GRANULARITIES_COMBINATIONS, TimestampGranularities |
|
9 | 9 |
|
10 |
-@pytest.mark.asyncio() |
|
10 |
+ |
|
11 |
+@pytest.mark.asyncio |
|
11 | 12 |
@pytest.mark.parametrize("timestamp_granularities", TIMESTAMP_GRANULARITIES_COMBINATIONS) |
12 | 13 |
async def test_api_json_response_format_and_timestamp_granularities_combinations( |
13 | 14 |
openai_client: AsyncOpenAI, |
... | ... | @@ -20,7 +21,7 @@ |
20 | 21 |
) |
21 | 22 |
|
22 | 23 |
|
23 |
-@pytest.mark.asyncio() |
|
24 |
+@pytest.mark.asyncio |
|
24 | 25 |
@pytest.mark.parametrize("timestamp_granularities", TIMESTAMP_GRANULARITIES_COMBINATIONS) |
25 | 26 |
async def test_api_verbose_json_response_format_and_timestamp_granularities_combinations( |
26 | 27 |
openai_client: AsyncOpenAI, |
--- tests/conftest.py
+++ tests/conftest.py
... | ... | @@ -3,11 +3,12 @@ |
3 | 3 |
import os |
4 | 4 |
|
5 | 5 |
from fastapi.testclient import TestClient |
6 |
-from faster_whisper_server.main import create_app |
|
7 | 6 |
from httpx import ASGITransport, AsyncClient |
8 | 7 |
from openai import AsyncOpenAI |
9 | 8 |
import pytest |
10 | 9 |
import pytest_asyncio |
10 |
+ |
|
11 |
+from faster_whisper_server.main import create_app |
|
11 | 12 |
|
12 | 13 |
disable_loggers = ["multipart.multipart", "faster_whisper"] |
13 | 14 |
|
... | ... | @@ -19,7 +20,7 @@ |
19 | 20 |
|
20 | 21 |
|
21 | 22 |
# NOTE: not being used. Keeping just in case |
22 |
-@pytest.fixture() |
|
23 |
+@pytest.fixture |
|
23 | 24 |
def client() -> Generator[TestClient, None, None]: |
24 | 25 |
os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en" |
25 | 26 |
with TestClient(create_app()) as client: |
... | ... | @@ -38,7 +39,7 @@ |
38 | 39 |
return AsyncOpenAI(api_key="cant-be-empty", http_client=aclient) |
39 | 40 |
|
40 | 41 |
|
41 |
-@pytest.fixture() |
|
42 |
+@pytest.fixture |
|
42 | 43 |
def actual_openai_client() -> AsyncOpenAI: |
43 | 44 |
return AsyncOpenAI( |
44 | 45 |
base_url="https://api.openai.com/v1" |
--- tests/openai_timestamp_granularities_test.py
+++ tests/openai_timestamp_granularities_test.py
... | ... | @@ -2,13 +2,14 @@ |
2 | 2 |
|
3 | 3 |
from pathlib import Path |
4 | 4 |
|
5 |
-from faster_whisper_server.api_models import TIMESTAMP_GRANULARITIES_COMBINATIONS, TimestampGranularities |
|
6 | 5 |
from openai import AsyncOpenAI, BadRequestError |
7 | 6 |
import pytest |
8 | 7 |
|
8 |
+from faster_whisper_server.api_models import TIMESTAMP_GRANULARITIES_COMBINATIONS, TimestampGranularities |
|
9 | 9 |
|
10 |
-@pytest.mark.asyncio() |
|
11 |
-@pytest.mark.requires_openai() |
|
10 |
+ |
|
11 |
+@pytest.mark.asyncio |
|
12 |
+@pytest.mark.requires_openai |
|
12 | 13 |
@pytest.mark.parametrize("timestamp_granularities", TIMESTAMP_GRANULARITIES_COMBINATIONS) |
13 | 14 |
async def test_openai_json_response_format_and_timestamp_granularities_combinations( |
14 | 15 |
actual_openai_client: AsyncOpenAI, |
... | ... | @@ -29,8 +30,8 @@ |
29 | 30 |
) |
30 | 31 |
|
31 | 32 |
|
32 |
-@pytest.mark.asyncio() |
|
33 |
-@pytest.mark.requires_openai() |
|
33 |
+@pytest.mark.asyncio |
|
34 |
+@pytest.mark.requires_openai |
|
34 | 35 |
@pytest.mark.parametrize("timestamp_granularities", TIMESTAMP_GRANULARITIES_COMBINATIONS) |
35 | 36 |
async def test_openai_verbose_json_response_format_and_timestamp_granularities_combinations( |
36 | 37 |
actual_openai_client: AsyncOpenAI, |
--- tests/sse_test.py
+++ tests/sse_test.py
... | ... | @@ -2,16 +2,17 @@ |
2 | 2 |
from pathlib import Path |
3 | 3 |
|
4 | 4 |
import anyio |
5 |
-from faster_whisper_server.api_models import ( |
|
6 |
- CreateTranscriptionResponseJson, |
|
7 |
- CreateTranscriptionResponseVerboseJson, |
|
8 |
-) |
|
9 | 5 |
from httpx import AsyncClient |
10 | 6 |
from httpx_sse import aconnect_sse |
11 | 7 |
import pytest |
12 | 8 |
import srt |
13 | 9 |
import webvtt |
14 | 10 |
import webvtt.vtt |
11 |
+ |
|
12 |
+from faster_whisper_server.api_models import ( |
|
13 |
+ CreateTranscriptionResponseJson, |
|
14 |
+ CreateTranscriptionResponseVerboseJson, |
|
15 |
+) |
|
15 | 16 |
|
16 | 17 |
FILE_PATHS = ["audio.wav"] # HACK |
17 | 18 |
ENDPOINTS = [ |
... | ... | @@ -23,7 +24,7 @@ |
23 | 24 |
parameters = [(file_path, endpoint) for endpoint in ENDPOINTS for file_path in FILE_PATHS] |
24 | 25 |
|
25 | 26 |
|
26 |
-@pytest.mark.asyncio() |
|
27 |
+@pytest.mark.asyncio |
|
27 | 28 |
@pytest.mark.parametrize(("file_path", "endpoint"), parameters) |
28 | 29 |
async def test_streaming_transcription_text(aclient: AsyncClient, file_path: str, endpoint: str) -> None: |
29 | 30 |
extension = Path(file_path).suffix[1:] |
... | ... | @@ -39,7 +40,7 @@ |
39 | 40 |
assert len(event.data) > 1 # HACK: 1 because of the space character that's always prepended |
40 | 41 |
|
41 | 42 |
|
42 |
-@pytest.mark.asyncio() |
|
43 |
+@pytest.mark.asyncio |
|
43 | 44 |
@pytest.mark.parametrize(("file_path", "endpoint"), parameters) |
44 | 45 |
async def test_streaming_transcription_json(aclient: AsyncClient, file_path: str, endpoint: str) -> None: |
45 | 46 |
extension = Path(file_path).suffix[1:] |
... | ... | @@ -54,7 +55,7 @@ |
54 | 55 |
CreateTranscriptionResponseJson(**json.loads(event.data)) |
55 | 56 |
|
56 | 57 |
|
57 |
-@pytest.mark.asyncio() |
|
58 |
+@pytest.mark.asyncio |
|
58 | 59 |
@pytest.mark.parametrize(("file_path", "endpoint"), parameters) |
59 | 60 |
async def test_streaming_transcription_verbose_json(aclient: AsyncClient, file_path: str, endpoint: str) -> None: |
60 | 61 |
extension = Path(file_path).suffix[1:] |
... | ... | @@ -69,7 +70,7 @@ |
69 | 70 |
CreateTranscriptionResponseVerboseJson(**json.loads(event.data)) |
70 | 71 |
|
71 | 72 |
|
72 |
-@pytest.mark.asyncio() |
|
73 |
+@pytest.mark.asyncio |
|
73 | 74 |
async def test_transcription_vtt(aclient: AsyncClient) -> None: |
74 | 75 |
async with await anyio.open_file("audio.wav", "rb") as f: |
75 | 76 |
data = await f.read() |
... | ... | @@ -87,7 +88,7 @@ |
87 | 88 |
webvtt.from_string(text) |
88 | 89 |
|
89 | 90 |
|
90 |
-@pytest.mark.asyncio() |
|
91 |
+@pytest.mark.asyncio |
|
91 | 92 |
async def test_transcription_srt(aclient: AsyncClient) -> None: |
92 | 93 |
async with await anyio.open_file("audio.wav", "rb") as f: |
93 | 94 |
data = await f.read() |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?