Skip to content

Commit 73a6e77

Browse files
committed
Apply pyupgrade fixes
1 parent 5461c8f commit 73a6e77

File tree

12 files changed

+49
-49
lines changed

12 files changed

+49
-49
lines changed

src/typesense/alias.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from typesense.types.alias import AliasSchema
2525

2626

27-
class Alias(object):
27+
class Alias:
2828
"""
2929
Class for managing individual aliases in Typesense.
3030

src/typesense/analytics_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717

1818

19-
class AnalyticsRules(object):
19+
class AnalyticsRules:
2020
resource_path: typing.Final[str] = "/analytics/rules"
2121

2222
def __init__(self, api_call: ApiCall) -> None:

src/typesense/analytics_rules_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
]
5151

5252

53-
class AnalyticsRulesV1(object):
53+
class AnalyticsRulesV1:
5454
"""
5555
Class for managing analytics rules in Typesense (V1).
5656

src/typesense/analytics_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
@deprecated("AnalyticsV1 is deprecated on v30+. Use client.analytics instead.")
27-
class AnalyticsV1(object):
27+
class AnalyticsV1:
2828
"""
2929
Class for managing analytics in Typesense (V1).
3030

src/typesense/api_call.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@
5959

6060
_SERVER_ERRORS: typing.Final[
6161
typing.Tuple[
62-
typing.Type[requests.exceptions.Timeout],
63-
typing.Type[requests.exceptions.ConnectionError],
64-
typing.Type[requests.exceptions.HTTPError],
65-
typing.Type[requests.exceptions.RequestException],
66-
typing.Type[requests.exceptions.SSLError],
67-
typing.Type[HTTPStatus0Error],
68-
typing.Type[ServerError],
69-
typing.Type[ServiceUnavailable],
62+
type[requests.exceptions.Timeout],
63+
type[requests.exceptions.ConnectionError],
64+
type[requests.exceptions.HTTPError],
65+
type[requests.exceptions.RequestException],
66+
type[requests.exceptions.SSLError],
67+
type[HTTPStatus0Error],
68+
type[ServerError],
69+
type[ServiceUnavailable],
7070
]
7171
] = (
7272
requests.exceptions.Timeout,
@@ -108,7 +108,7 @@ def __init__(self, config: Configuration):
108108
def get(
109109
self,
110110
endpoint: str,
111-
entity_type: typing.Type[TEntityDict],
111+
entity_type: type[TEntityDict],
112112
as_json: typing.Literal[False],
113113
params: typing.Union[TParams, None] = None,
114114
) -> str:
@@ -129,7 +129,7 @@ def get(
129129
def get(
130130
self,
131131
endpoint: str,
132-
entity_type: typing.Type[TEntityDict],
132+
entity_type: type[TEntityDict],
133133
as_json: typing.Literal[True],
134134
params: typing.Union[TParams, None] = None,
135135
) -> TEntityDict:
@@ -149,7 +149,7 @@ def get(
149149
def get(
150150
self,
151151
endpoint: str,
152-
entity_type: typing.Type[TEntityDict],
152+
entity_type: type[TEntityDict],
153153
as_json: typing.Union[typing.Literal[True], typing.Literal[False]] = True,
154154
params: typing.Union[TParams, None] = None,
155155
) -> typing.Union[TEntityDict, str]:
@@ -177,7 +177,7 @@ def get(
177177
def post(
178178
self,
179179
endpoint: str,
180-
entity_type: typing.Type[TEntityDict],
180+
entity_type: type[TEntityDict],
181181
as_json: typing.Literal[False],
182182
params: typing.Union[TParams, None] = None,
183183
body: typing.Union[TBody, None] = None,
@@ -199,7 +199,7 @@ def post(
199199
def post(
200200
self,
201201
endpoint: str,
202-
entity_type: typing.Type[TEntityDict],
202+
entity_type: type[TEntityDict],
203203
as_json: typing.Literal[True],
204204
params: typing.Union[TParams, None] = None,
205205
body: typing.Union[TBody, None] = None,
@@ -220,7 +220,7 @@ def post(
220220
def post(
221221
self,
222222
endpoint: str,
223-
entity_type: typing.Type[TEntityDict],
223+
entity_type: type[TEntityDict],
224224
as_json: typing.Union[typing.Literal[True], typing.Literal[False]] = True,
225225
params: typing.Union[TParams, None] = None,
226226
body: typing.Union[TBody, None] = None,
@@ -249,7 +249,7 @@ def post(
249249
def put(
250250
self,
251251
endpoint: str,
252-
entity_type: typing.Type[TEntityDict],
252+
entity_type: type[TEntityDict],
253253
body: TBody,
254254
params: typing.Union[TParams, None] = None,
255255
) -> TEntityDict:
@@ -276,7 +276,7 @@ def put(
276276
def patch(
277277
self,
278278
endpoint: str,
279-
entity_type: typing.Type[TEntityDict],
279+
entity_type: type[TEntityDict],
280280
body: TBody,
281281
params: typing.Union[TParams, None] = None,
282282
) -> TEntityDict:
@@ -303,7 +303,7 @@ def patch(
303303
def delete(
304304
self,
305305
endpoint: str,
306-
entity_type: typing.Type[TEntityDict],
306+
entity_type: type[TEntityDict],
307307
params: typing.Union[TParams, None] = None,
308308
) -> TEntityDict:
309309
"""
@@ -330,7 +330,7 @@ def _execute_request(
330330
self,
331331
fn: typing.Callable[..., requests.models.Response],
332332
endpoint: str,
333-
entity_type: typing.Type[TEntityDict],
333+
entity_type: type[TEntityDict],
334334
as_json: typing.Literal[True],
335335
last_exception: typing.Union[None, Exception] = None,
336336
num_retries: int = 0,
@@ -369,7 +369,7 @@ def _execute_request(
369369
self,
370370
fn: typing.Callable[..., requests.models.Response],
371371
endpoint: str,
372-
entity_type: typing.Type[TEntityDict],
372+
entity_type: type[TEntityDict],
373373
as_json: typing.Literal[False],
374374
last_exception: typing.Union[None, Exception] = None,
375375
num_retries: int = 0,
@@ -407,7 +407,7 @@ def _execute_request(
407407
self,
408408
fn: typing.Callable[..., requests.models.Response],
409409
endpoint: str,
410-
entity_type: typing.Type[TEntityDict],
410+
entity_type: type[TEntityDict],
411411
as_json: typing.Union[typing.Literal[True], typing.Literal[False]] = True,
412412
last_exception: typing.Union[None, Exception] = None,
413413
num_retries: int = 0,
@@ -471,7 +471,7 @@ def _make_request_and_process_response(
471471
self,
472472
fn: typing.Callable[..., requests.models.Response],
473473
url: str,
474-
entity_type: typing.Type[TEntityDict],
474+
entity_type: type[TEntityDict],
475475
as_json: bool,
476476
**kwargs: SessionFunctionKwargs[TParams, TBody],
477477
) -> typing.Union[TEntityDict, str]:

src/typesense/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def analyticsV1(self) -> AnalyticsV1:
133133
def typed_collection(
134134
self,
135135
*,
136-
model: typing.Type[TDoc],
136+
model: type[TDoc],
137137
name: typing.Union[str, None] = None,
138138
) -> Collection[TDoc]:
139139
"""

src/typesense/configuration.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class NodeConfigDict(typing.TypedDict):
4444
host: str
4545
port: int
4646
path: typing.NotRequired[str]
47-
protocol: typing.Union[typing.Literal["http", "https"], str]
47+
protocol: typing.Literal["http", "https"] | str
4848

4949

5050
class ConfigDict(typing.TypedDict):
@@ -84,18 +84,18 @@ class ConfigDict(typing.TypedDict):
8484
suppress_deprecation_warnings (bool): Whether to suppress deprecation warnings.
8585
"""
8686

87-
nodes: typing.List[typing.Union[str, NodeConfigDict]]
88-
nearest_node: typing.NotRequired[typing.Union[str, NodeConfigDict]]
87+
nodes: typing.List[str | NodeConfigDict]
88+
nearest_node: typing.NotRequired[str | NodeConfigDict]
8989
api_key: str
9090
num_retries: typing.NotRequired[int]
9191
interval_seconds: typing.NotRequired[int]
9292
healthcheck_interval_seconds: typing.NotRequired[int]
9393
verify: typing.NotRequired[bool]
9494
timeout_seconds: typing.NotRequired[int] # deprecated
95-
master_node: typing.NotRequired[typing.Union[str, NodeConfigDict]] # deprecated
95+
master_node: typing.NotRequired[str | NodeConfigDict] # deprecated
9696
additional_headers: typing.NotRequired[typing.Dict[str, str]]
9797
read_replica_nodes: typing.NotRequired[
98-
typing.List[typing.Union[str, NodeConfigDict]]
98+
typing.List[str | NodeConfigDict]
9999
] # deprecated
100100
connection_timeout_seconds: typing.NotRequired[float]
101101
suppress_deprecation_warnings: typing.NotRequired[bool]
@@ -116,9 +116,9 @@ class Node:
116116
def __init__(
117117
self,
118118
host: str,
119-
port: typing.Union[str, int],
119+
port: str | int,
120120
path: str,
121-
protocol: typing.Union[typing.Literal["http", "https"], str],
121+
protocol: typing.Literal["http", "https"] | str,
122122
) -> None:
123123
"""
124124
Initialize a Node object with the specified host, port, path, and protocol.
@@ -141,7 +141,7 @@ def __init__(
141141
self.last_access_ts: int = int(time.time())
142142

143143
@classmethod
144-
def from_url(cls, url: str) -> "Node":
144+
def from_url(cls, url: str) -> Node:
145145
"""
146146
Initialize a Node object from a URL string.
147147
@@ -227,8 +227,8 @@ def __init__(
227227

228228
def _handle_nearest_node(
229229
self,
230-
nearest_node: typing.Union[str, NodeConfigDict, None],
231-
) -> typing.Union[Node, None]:
230+
nearest_node: str | NodeConfigDict | None,
231+
) -> Node | None:
232232
"""
233233
Handle the nearest node configuration.
234234
@@ -244,7 +244,7 @@ def _handle_nearest_node(
244244

245245
def _initialize_nodes(
246246
self,
247-
node: typing.Union[str, NodeConfigDict],
247+
node: str | NodeConfigDict,
248248
) -> Node:
249249
"""
250250
Handle the initialization of a node.
@@ -305,7 +305,7 @@ def validate_required_config_fields(config_dict: ConfigDict) -> None:
305305
raise ConfigError("`api_key` is not defined.")
306306

307307
@staticmethod
308-
def validate_nodes(nodes: typing.List[typing.Union[str, NodeConfigDict]]) -> None:
308+
def validate_nodes(nodes: typing.List[str | NodeConfigDict]) -> None:
309309
"""
310310
Validate the nodes in the configuration dictionary.
311311
@@ -328,7 +328,7 @@ def validate_nodes(nodes: typing.List[typing.Union[str, NodeConfigDict]]) -> Non
328328
)
329329

330330
@staticmethod
331-
def validate_nearest_node(nearest_node: typing.Union[str, NodeConfigDict]) -> None:
331+
def validate_nearest_node(nearest_node: str | NodeConfigDict) -> None:
332332
"""
333333
Validate the nearest node in the configuration dictionary.
334334
@@ -350,7 +350,7 @@ def validate_nearest_node(nearest_node: typing.Union[str, NodeConfigDict]) -> No
350350
)
351351

352352
@staticmethod
353-
def validate_node_fields(node: typing.Union[str, NodeConfigDict]) -> bool:
353+
def validate_node_fields(node: str | NodeConfigDict) -> bool:
354354
"""
355355
Validate the fields of a node in the configuration dictionary.
356356

src/typesense/conversations_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from typesense.conversation_model import ConversationModel
4444

4545

46-
class ConversationsModels(object):
46+
class ConversationsModels:
4747
"""
4848
Class for managing conversation models in Typesense.
4949

src/typesense/nl_search_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from typesense.nl_search_model import NLSearchModel
4141

4242

43-
class NLSearchModels(object):
43+
class NLSearchModels:
4444
"""
4545
Class for managing NL search models in Typesense.
4646

src/typesense/overrides.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def retrieve(self) -> OverrideRetrieveSchema:
133133
)
134134
return response
135135

136-
def _endpoint_path(self, override_id: typing.Union[str, None] = None) -> str:
136+
def _endpoint_path(self, override_id: str | None = None) -> str:
137137
"""
138138
Construct the API endpoint path for override operations.
139139

0 commit comments

Comments
 (0)