Skip to content

Commit 8bdd445

Browse files
author
Lemonyte
committed
Remove usage of future annotations
1 parent e91b586 commit 8bdd445

File tree

13 files changed

+60
-99
lines changed

13 files changed

+60
-99
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ version = {attr = "contiguity.__version__"}
6161
[tool.ruff]
6262
src = ["src"]
6363
line-length = 119
64-
target-version = "py39"
64+
target-version = "py310"
6565

6666
[tool.ruff.lint]
6767
select = ["ALL"]

src/contiguity/_auth.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import os
42

53

src/contiguity/_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from http import HTTPStatus
42

53
from httpx import AsyncClient as HttpxAsyncClient
@@ -24,7 +22,7 @@ def handle_error(self, response: Response, /, *, fail_message: str = "api reques
2422

2523
class ApiClient(HttpxClient, BaseApiClient):
2624
def __init__(
27-
self: ApiClient,
25+
self: "ApiClient",
2826
*,
2927
base_url: str = "https://api.contiguity.com",
3028
api_key: str | None = None,
@@ -44,7 +42,7 @@ def __init__(
4442

4543
class AsyncApiClient(HttpxAsyncClient, BaseApiClient):
4644
def __init__(
47-
self: AsyncApiClient,
45+
self: "AsyncApiClient",
4846
*,
4947
base_url: str = "https://api.contiguity.com",
5048
api_key: str | None = None,

src/contiguity/_instant_messaging.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
from __future__ import annotations
2-
31
import logging
42
from abc import ABC, abstractmethod
5-
from typing import TYPE_CHECKING, Generic, Literal, TypeVar
3+
from collections.abc import Sequence
4+
from typing import Generic, Literal, TypeVar
65

76
from ._product import BaseProduct
87
from ._response import BaseResponse, decode_response
98

10-
if TYPE_CHECKING:
11-
from collections.abc import Sequence
12-
139
FallbackCauseT = TypeVar("FallbackCauseT", bound=str)
1410

1511
logger = logging.getLogger(__name__)

src/contiguity/_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from collections.abc import Sequence
22
from http import HTTPStatus
3-
from typing import Generic, TypeVar, Union
3+
from typing import Generic, TypeVar
44

55
import msgspec
66

7-
T = TypeVar("T", bound=Union[msgspec.Struct, Sequence[msgspec.Struct]])
7+
T = TypeVar("T", bound=msgspec.Struct | Sequence[msgspec.Struct])
88

99

1010
class ResponseMetadata(msgspec.Struct):

src/contiguity/base/async_base.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
from __future__ import annotations
2-
31
import json
42
import os
53
from collections.abc import Mapping, Sequence
64
from datetime import datetime, timedelta, timezone
75
from http import HTTPStatus
8-
from typing import TYPE_CHECKING, Generic, Literal, overload
6+
from typing import Generic, Literal, overload
97
from warnings import warn
108

119
import msgspec
1210
from httpx import HTTPStatusError
11+
from httpx import Response as HttpxResponse
1312
from typing_extensions import deprecated
1413

1514
from contiguity._auth import get_data_key, get_project_id
@@ -31,18 +30,14 @@
3130
)
3231
from .exceptions import ItemConflictError, ItemNotFoundError
3332

34-
if TYPE_CHECKING:
35-
from httpx import Response as HttpxResponse
36-
from typing_extensions import Self
37-
3833

3934
class AsyncBase(Generic[ItemT]):
4035
EXPIRES_ATTRIBUTE = "__expires"
4136
PUT_LIMIT = 30
4237

4338
@overload
4439
def __init__(
45-
self: Self,
40+
self,
4641
name: str,
4742
/,
4843
*,
@@ -57,7 +52,7 @@ def __init__(
5752
@overload
5853
@deprecated("The `project_key` parameter has been renamed to `data_key`.")
5954
def __init__(
60-
self: Self,
55+
self,
6156
name: str,
6257
/,
6358
*,
@@ -70,7 +65,7 @@ def __init__(
7065
) -> None: ...
7166

7267
def __init__( # noqa: PLR0913
73-
self: Self,
68+
self,
7469
name: str,
7570
/,
7671
*,
@@ -102,23 +97,23 @@ def __init__( # noqa: PLR0913
10297

10398
@overload
10499
def _response_as_item_type(
105-
self: Self,
100+
self,
106101
response: HttpxResponse,
107102
/,
108103
*,
109104
sequence: Literal[False] = False,
110105
) -> ItemT: ...
111106
@overload
112107
def _response_as_item_type(
113-
self: Self,
108+
self,
114109
response: HttpxResponse,
115110
/,
116111
*,
117112
sequence: Literal[True] = True,
118113
) -> Sequence[ItemT]: ...
119114

120115
def _response_as_item_type(
121-
self: Self,
116+
self,
122117
response: HttpxResponse,
123118
/,
124119
*,
@@ -133,7 +128,7 @@ def _response_as_item_type(
133128
return response.json(cls=self.json_decoder)
134129

135130
def _insert_expires_attr(
136-
self: Self,
131+
self,
137132
item: ItemT | Mapping[str, DataType],
138133
expire_in: int | None = None,
139134
expire_at: TimestampType | None = None,
@@ -158,16 +153,16 @@ def _insert_expires_attr(
158153
return item_dict
159154

160155
@overload
161-
async def get(self: Self, key: str, /) -> ItemT | None: ...
156+
async def get(self, key: str, /) -> ItemT | None: ...
162157

163158
@overload
164-
async def get(self: Self, key: str, /, *, default: ItemT) -> ItemT: ...
159+
async def get(self, key: str, /, *, default: ItemT) -> ItemT: ...
165160

166161
@overload
167-
async def get(self: Self, key: str, /, *, default: DefaultItemT) -> ItemT | DefaultItemT: ...
162+
async def get(self, key: str, /, *, default: DefaultItemT) -> ItemT | DefaultItemT: ...
168163

169164
async def get(
170-
self: Self,
165+
self,
171166
key: str,
172167
/,
173168
*,
@@ -187,7 +182,7 @@ async def get(
187182

188183
return self._response_as_item_type(response, sequence=False)
189184

190-
async def delete(self: Self, key: str, /) -> None:
185+
async def delete(self, key: str, /) -> None:
191186
"""Delete an item from the Base."""
192187
key = check_key(key)
193188
response = await self._client.delete(f"/items/{key}")
@@ -197,7 +192,7 @@ async def delete(self: Self, key: str, /) -> None:
197192
raise ContiguityApiError(exc.response.text) from exc
198193

199194
async def insert(
200-
self: Self,
195+
self,
201196
item: ItemT,
202197
/,
203198
*,
@@ -216,7 +211,7 @@ async def insert(
216211
return returned_item[0]
217212

218213
async def put(
219-
self: Self,
214+
self,
220215
*items: ItemT,
221216
expire_in: int | None = None,
222217
expire_at: TimestampType | None = None,
@@ -237,7 +232,7 @@ async def put(
237232

238233
@deprecated("This method will be removed in a future release. You can pass multiple items to `put`.")
239234
async def put_many(
240-
self: Self,
235+
self,
241236
items: Sequence[ItemT],
242237
/,
243238
*,
@@ -247,7 +242,7 @@ async def put_many(
247242
return await self.put(*items, expire_in=expire_in, expire_at=expire_at)
248243

249244
async def update(
250-
self: Self,
245+
self,
251246
updates: Mapping[str, DataType | UpdateOperation],
252247
/,
253248
*,
@@ -278,7 +273,7 @@ async def update(
278273
return self._response_as_item_type(response, sequence=False)
279274

280275
async def query(
281-
self: Self,
276+
self,
282277
*queries: QueryType,
283278
limit: int = 1000,
284279
last: str | None = None,
@@ -310,7 +305,7 @@ async def query(
310305

311306
@deprecated("This method has been renamed to `query` and will be removed in a future release.")
312307
async def fetch(
313-
self: Self,
308+
self,
314309
*queries: QueryType,
315310
limit: int = 1000,
316311
last: str | None = None,

0 commit comments

Comments
 (0)