Skip to content

Commit d0f7068

Browse files
Merge pull request #328 from dvonthenen/fix-pyright-v3.1.5
Fix `pyright` Defintions for `3.1.5`
2 parents addbd4e + efe854f commit d0f7068

File tree

16 files changed

+381
-252
lines changed

16 files changed

+381
-252
lines changed

deepgram/audio/microphone/microphone.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import inspect
66
import asyncio
77
import threading
8-
from array import array
8+
from typing import Optional
99
import logging, verboselogs
1010

1111
from .errors import DeepgramMicrophoneError
@@ -24,7 +24,7 @@ def __init__(
2424
rate: int = RATE,
2525
chunk: int = CHUNK,
2626
channels: int = CHANNELS,
27-
input_device_index: int = None,
27+
input_device_index: Optional[int] = None,
2828
):
2929
# dynamic import of pyaudio as not to force the requirements on the SDK (and users)
3030
import pyaudio

deepgram/client.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
33
# SPDX-License-Identifier: MIT
44

5-
from typing import Union
5+
from typing import Optional
66
from importlib import import_module
77
import logging, verboselogs
88
import os
@@ -152,7 +152,7 @@ class DeepgramClient:
152152
def __init__(
153153
self,
154154
api_key: str = "",
155-
config: DeepgramClientOptions = None,
155+
config: Optional[DeepgramClientOptions] = None,
156156
):
157157
verboselogs.install()
158158
self.logger = logging.getLogger(__name__)
@@ -175,27 +175,27 @@ def __init__(
175175
self.config = config
176176

177177
@property
178-
def listen(self) -> Listen:
178+
def listen(self):
179179
return Listen(self.config)
180180

181181
@property
182-
def read(self) -> Read:
182+
def read(self):
183183
return Read(self.config)
184184

185185
@property
186-
def manage(self) -> ManageClient:
186+
def manage(self):
187187
return self.Version(self.config, "manage")
188188

189189
@property
190-
def asyncmanage(self) -> AsyncManageClient:
190+
def asyncmanage(self):
191191
return self.Version(self.config, "asyncmanage")
192192

193193
@property
194-
def onprem(self) -> OnPremClient:
194+
def onprem(self):
195195
return self.Version(self.config, "onprem")
196196

197197
@property
198-
def asynconprem(self) -> AsyncOnPremClient:
198+
def asynconprem(self):
199199
return self.Version(self.config, "asynconprem")
200200

201201
# INTERNAL CLASSES
@@ -219,9 +219,7 @@ def __init__(self, config, parent: str):
219219
# case _:
220220
# raise DeepgramModuleError("Invalid parent")
221221

222-
def v(
223-
self, version: str = ""
224-
) -> Union[ManageClient, AsyncManageClient, OnPremClient, AsyncOnPremClient]:
222+
def v(self, version: str = ""):
225223
self.logger.debug("Version.v ENTER")
226224
self.logger.info("version: %s", version)
227225
if len(version) == 0:

deepgram/clients/abstract_async_client.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import httpx
66
import json
7-
from typing import Dict
7+
from typing import Dict, Optional
88

99
from .helpers import append_query_params
1010
from ..options import DeepgramClientOptions
@@ -38,9 +38,9 @@ def __init__(self, config: DeepgramClientOptions):
3838
async def get(
3939
self,
4040
url: str,
41-
options: Dict = None,
42-
addons: Dict = None,
43-
timeout: httpx.Timeout = None,
41+
options: Optional[Dict] = None,
42+
addons: Optional[Dict] = None,
43+
timeout: Optional[httpx.Timeout] = None,
4444
**kwargs
4545
) -> str:
4646
return await self._handle_request(
@@ -56,9 +56,9 @@ async def get(
5656
async def post(
5757
self,
5858
url: str,
59-
options: Dict = None,
60-
addons: Dict = None,
61-
timeout: httpx.Timeout = None,
59+
options: Optional[Dict] = None,
60+
addons: Optional[Dict] = None,
61+
timeout: Optional[httpx.Timeout] = None,
6262
**kwargs
6363
) -> str:
6464
return await self._handle_request(
@@ -74,9 +74,9 @@ async def post(
7474
async def put(
7575
self,
7676
url: str,
77-
options: Dict = None,
78-
addons: Dict = None,
79-
timeout: httpx.Timeout = None,
77+
options: Optional[Dict] = None,
78+
addons: Optional[Dict] = None,
79+
timeout: Optional[httpx.Timeout] = None,
8080
**kwargs
8181
) -> str:
8282
return await self._handle_request(
@@ -92,9 +92,9 @@ async def put(
9292
async def patch(
9393
self,
9494
url: str,
95-
options: Dict = None,
96-
addons: Dict = None,
97-
timeout: httpx.Timeout = None,
95+
options: Optional[Dict] = None,
96+
addons: Optional[Dict] = None,
97+
timeout: Optional[httpx.Timeout] = None,
9898
**kwargs
9999
) -> str:
100100
return await self._handle_request(
@@ -110,9 +110,9 @@ async def patch(
110110
async def delete(
111111
self,
112112
url: str,
113-
options: Dict = None,
114-
addons: Dict = None,
115-
timeout: httpx.Timeout = None,
113+
options: Optional[Dict] = None,
114+
addons: Optional[Dict] = None,
115+
timeout: Optional[httpx.Timeout] = None,
116116
**kwargs
117117
) -> str:
118118
return await self._handle_request(
@@ -129,10 +129,10 @@ async def _handle_request(
129129
self,
130130
method: str,
131131
url: str,
132-
params: Dict = None,
133-
addons: Dict = None,
134-
timeout: httpx.Timeout = None,
135-
headers: Dict = None,
132+
params: Optional[Dict] = None,
133+
addons: Optional[Dict] = None,
134+
timeout: Optional[httpx.Timeout] = None,
135+
headers: Optional[Dict] = None,
136136
**kwargs
137137
) -> str:
138138
new_url = url

deepgram/clients/abstract_sync_client.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import httpx
66
import json
7-
from typing import Dict
7+
from typing import Dict, Optional
88

99
from .helpers import append_query_params
1010
from ..options import DeepgramClientOptions
@@ -37,9 +37,9 @@ def __init__(self, config: DeepgramClientOptions):
3737
def get(
3838
self,
3939
url: str,
40-
options: Dict = None,
41-
addons: Dict = None,
42-
timeout: httpx.Timeout = None,
40+
options: Optional[Dict] = None,
41+
addons: Optional[Dict] = None,
42+
timeout: Optional[httpx.Timeout] = None,
4343
**kwargs
4444
) -> str:
4545
return self._handle_request(
@@ -55,9 +55,9 @@ def get(
5555
def post(
5656
self,
5757
url: str,
58-
options: Dict = None,
59-
addons: Dict = None,
60-
timeout: httpx.Timeout = None,
58+
options: Optional[Dict] = None,
59+
addons: Optional[Dict] = None,
60+
timeout: Optional[httpx.Timeout] = None,
6161
**kwargs
6262
) -> str:
6363
return self._handle_request(
@@ -73,9 +73,9 @@ def post(
7373
def put(
7474
self,
7575
url: str,
76-
options: Dict = None,
77-
addons: Dict = None,
78-
timeout: httpx.Timeout = None,
76+
options: Optional[Dict] = None,
77+
addons: Optional[Dict] = None,
78+
timeout: Optional[httpx.Timeout] = None,
7979
**kwargs
8080
) -> str:
8181
return self._handle_request(
@@ -91,9 +91,9 @@ def put(
9191
def patch(
9292
self,
9393
url: str,
94-
options: Dict = None,
95-
addons: Dict = None,
96-
timeout: httpx.Timeout = None,
94+
options: Optional[Dict] = None,
95+
addons: Optional[Dict] = None,
96+
timeout: Optional[httpx.Timeout] = None,
9797
**kwargs
9898
) -> str:
9999
return self._handle_request(
@@ -109,9 +109,9 @@ def patch(
109109
def delete(
110110
self,
111111
url: str,
112-
options: Dict = None,
113-
addons: Dict = None,
114-
timeout: httpx.Timeout = None,
112+
options: Optional[Dict] = None,
113+
addons: Optional[Dict] = None,
114+
timeout: Optional[httpx.Timeout] = None,
115115
**kwargs
116116
) -> str:
117117
return self._handle_request(
@@ -128,10 +128,10 @@ def _handle_request(
128128
self,
129129
method: str,
130130
url: str,
131-
params: Dict = None,
132-
addons: Dict = None,
133-
timeout: httpx.Timeout = None,
134-
headers: Dict = None,
131+
params: Optional[Dict] = None,
132+
addons: Optional[Dict] = None,
133+
timeout: Optional[httpx.Timeout] = None,
134+
headers: Optional[Dict] = None,
135135
**kwargs
136136
) -> str:
137137
new_url = url

deepgram/clients/analyze/v1/async_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import httpx
66
import logging, verboselogs
77
import json
8-
from typing import Dict, Union
8+
from typing import Dict, Union, Optional
99

1010
from ...abstract_async_client import AbstractAsyncRestClient
1111
from ..errors import DeepgramError, DeepgramTypeError
@@ -54,9 +54,9 @@ def __init__(self, config):
5454
async def analyze_url(
5555
self,
5656
source: UrlSource,
57-
options: Union[AnalyzeOptions, Dict] = None,
58-
addons: Dict = None,
59-
timeout: httpx.Timeout = None,
57+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
58+
addons: Optional[Dict] = None,
59+
timeout: Optional[httpx.Timeout] = None,
6060
endpoint: str = "v1/read",
6161
) -> AnalyzeResponse:
6262
self.logger.debug("AsyncAnalyzeClient.analyze_url ENTER")
@@ -117,9 +117,9 @@ async def analyze_url_callback(
117117
self,
118118
source: UrlSource,
119119
callback: str,
120-
options: Union[AnalyzeOptions, Dict] = None,
121-
addons: Dict = None,
122-
timeout: httpx.Timeout = None,
120+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
121+
addons: Optional[Dict] = None,
122+
timeout: Optional[httpx.Timeout] = None,
123123
endpoint: str = "v1/read",
124124
) -> AsyncAnalyzeResponse:
125125
self.logger.debug("AnalyzeClient.analyze_url_callback ENTER")
@@ -178,9 +178,9 @@ async def analyze_url_callback(
178178
async def analyze_text(
179179
self,
180180
source: TextSource,
181-
options: Union[AnalyzeOptions, Dict] = None,
182-
addons: Dict = None,
183-
timeout: httpx.Timeout = None,
181+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
182+
addons: Optional[Dict] = None,
183+
timeout: Optional[httpx.Timeout] = None,
184184
endpoint: str = "v1/read",
185185
) -> AnalyzeResponse:
186186
self.logger.debug("AsyncAnalyzeClient.analyze_text ENTER")
@@ -242,9 +242,9 @@ async def analyze_text_callback(
242242
self,
243243
source: TextSource,
244244
callback: str,
245-
options: Union[AnalyzeOptions, Dict] = None,
246-
addons: Dict = None,
247-
timeout: httpx.Timeout = None,
245+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
246+
addons: Optional[Dict] = None,
247+
timeout: Optional[httpx.Timeout] = None,
248248
endpoint: str = "v1/read",
249249
) -> AsyncAnalyzeResponse:
250250
self.logger.debug("AnalyzeClient.analyze_text_callback ENTER")

deepgram/clients/analyze/v1/client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import httpx
66
import logging, verboselogs
77
import json
8-
from typing import Dict, Union
8+
from typing import Dict, Union, Optional
99

1010
from ...abstract_sync_client import AbstractSyncRestClient
1111
from ..errors import DeepgramError, DeepgramTypeError
@@ -54,11 +54,11 @@ def __init__(self, config):
5454
def analyze_url(
5555
self,
5656
source: UrlSource,
57-
options: Union[AnalyzeOptions, Dict] = None,
58-
addons: Dict = None,
59-
timeout: httpx.Timeout = None,
57+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
58+
addons: Optional[Dict] = None,
59+
timeout: Optional[httpx.Timeout] = None,
6060
endpoint: str = "v1/read",
61-
) -> AnalyzeResponse:
61+
) -> Union[AnalyzeResponse, AsyncAnalyzeResponse]:
6262
self.logger.debug("AnalyzeClient.analyze_url ENTER")
6363

6464
if (options is Dict and "callback" in options is not None) or (
@@ -119,9 +119,9 @@ def analyze_url_callback(
119119
self,
120120
source: UrlSource,
121121
callback: str,
122-
options: Union[AnalyzeOptions, Dict] = None,
123-
addons: Dict = None,
124-
timeout: httpx.Timeout = None,
122+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
123+
addons: Optional[Dict] = None,
124+
timeout: Optional[httpx.Timeout] = None,
125125
endpoint: str = "v1/read",
126126
) -> AsyncAnalyzeResponse:
127127
self.logger.debug("AnalyzeClient.analyze_url_callback ENTER")
@@ -180,11 +180,11 @@ def analyze_url_callback(
180180
def analyze_text(
181181
self,
182182
source: TextSource,
183-
options: Union[AnalyzeOptions, Dict] = None,
184-
addons: Dict = None,
185-
timeout: httpx.Timeout = None,
183+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
184+
addons: Optional[Dict] = None,
185+
timeout: Optional[httpx.Timeout] = None,
186186
endpoint: str = "v1/read",
187-
) -> AnalyzeResponse:
187+
) -> Union[AnalyzeResponse, AsyncAnalyzeResponse]:
188188
self.logger.debug("AnalyzeClient.analyze_text ENTER")
189189

190190
if (options is Dict and "callback" in options is not None) or (
@@ -246,9 +246,9 @@ def analyze_file_callback(
246246
self,
247247
source: TextSource,
248248
callback: str,
249-
options: Union[AnalyzeOptions, Dict] = None,
250-
addons: Dict = None,
251-
timeout: httpx.Timeout = None,
249+
options: Optional[Union[AnalyzeOptions, Dict]] = None,
250+
addons: Optional[Dict] = None,
251+
timeout: Optional[httpx.Timeout] = None,
252252
endpoint: str = "v1/read",
253253
) -> AsyncAnalyzeResponse:
254254
self.logger.debug("AnalyzeClient.analyze_file_callback ENTER")

0 commit comments

Comments
 (0)