Skip to content

Commit d9d7a2b

Browse files
committed
ruff formatter
1 parent 61c7a30 commit d9d7a2b

23 files changed

+181
-168
lines changed

jigsawstack/classification.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class DatasetItem(TypedDict):
10-
type: Union[Literal["text"], Literal["image"]]
10+
type: Literal["text", "image"]
1111
"""
1212
Type of the dataset item: text
1313
"""
@@ -24,7 +24,7 @@ class LabelItem(TypedDict):
2424
Optional key for the label
2525
"""
2626

27-
type: Union[Literal["text"], Literal["image"]]
27+
type: Literal["text", "image"]
2828
"""
2929
Type of the label: text
3030
"""
@@ -60,7 +60,6 @@ class ClassificationResponse(BaseResponse):
6060

6161

6262
class Classification(ClientConfig):
63-
6463
config: RequestConfig
6564

6665
def __init__(

jigsawstack/embedding.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class EmbeddingResponse(BaseResponse):
2828

2929

3030
class Embedding(ClientConfig):
31-
3231
config: RequestConfig
3332

3433
def __init__(
@@ -83,7 +82,6 @@ def execute(
8382

8483

8584
class AsyncEmbedding(ClientConfig):
86-
8785
config: RequestConfig
8886

8987
def __init__(

jigsawstack/exceptions.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def __init__(
3939

4040

4141
class MissingApiKeyError(JigsawStackError):
42-
4342
def __init__(
4443
self,
4544
message: str,
@@ -61,8 +60,6 @@ def __init__(
6160

6261

6362
class InvalidApiKeyError(JigsawStackError):
64-
65-
6663
def __init__(
6764
self,
6865
message: str,
@@ -81,8 +78,6 @@ def __init__(
8178

8279

8380
class ValidationError(JigsawStackError):
84-
85-
8681
def __init__(
8782
self,
8883
message: str,
@@ -108,7 +103,6 @@ def __init__(
108103

109104

110105
class MissingRequiredFieldsError(JigsawStackError):
111-
112106
def __init__(
113107
self,
114108
message: str,
@@ -134,8 +128,6 @@ def __init__(
134128

135129

136130
class ApplicationError(JigsawStackError):
137-
138-
139131
def __init__(
140132
self,
141133
message: str,
@@ -173,7 +165,7 @@ def __init__(
173165

174166

175167
def raise_for_code_and_type(
176-
code: Union[str, int], message: str, err : Union[str, Dict[str, Any]] = None
168+
code: Union[str, int], message: str, err: Union[str, Dict[str, Any]] = None
177169
) -> None:
178170
"""Raise the appropriate error based on the code and type.
179171
@@ -201,14 +193,10 @@ def raise_for_code_and_type(
201193

202194
# Handle the case where the error might be unknown
203195
if error is None:
204-
raise JigsawStackError(
205-
code=code, message=message, err=err, suggested_action=""
206-
)
196+
raise JigsawStackError(code=code, message=message, err=err, suggested_action="")
207197

208198
# defaults to JigsawStackError if finally can't find error type
209-
raise JigsawStackError(
210-
code=code, message=message, err=err, suggested_action=""
211-
)
199+
raise JigsawStackError(code=code, message=message, err=err, suggested_action="")
212200

213201

214202
class NoContentError(Exception):
@@ -217,4 +205,4 @@ class NoContentError(Exception):
217205
def __init__(self) -> None:
218206
self.message = """No content was returned from the API.
219207
Please contact Jigsawstack support."""
220-
Exception.__init__(self, self.message)
208+
Exception.__init__(self, self.message)

jigsawstack/geo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class GeohashDecodeResponse(BaseResponse):
193193

194194

195195
class Geo(ClientConfig):
196-
197196
config: RequestConfig
198197

199198
def __init__(
@@ -301,7 +300,6 @@ def geohash(self, key: str) -> GeohashDecodeResponse:
301300

302301

303302
class AsyncGeo(ClientConfig):
304-
305303
config: AsyncRequestConfig
306304

307305
def __init__(

jigsawstack/helpers.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
21
from typing import Dict, Optional, Union
32
from urllib.parse import urlencode
43

5-
def build_path(base_path: str, params: Optional[Dict[str, Union[str, int, bool]]] = None) -> str:
4+
5+
def build_path(
6+
base_path: str, params: Optional[Dict[str, Union[str, int, bool]]] = None
7+
) -> str:
68
"""
79
Build an API endpoint path with query parameters.
810
@@ -15,11 +17,13 @@ def build_path(base_path: str, params: Optional[Dict[str, Union[str, int, bool]]
1517
"""
1618
if params is None:
1719
return base_path
18-
19-
#remove None values from the parameters
20-
filtered_params = { k: str(v).lower() if isinstance(v, bool) else v for k, v in params.items() if v is not None}
21-
22-
#encode the parameters
23-
return f"{base_path}?{urlencode(filtered_params)}" if filtered_params else base_path
2420

21+
# remove None values from the parameters
22+
filtered_params = {
23+
k: str(v).lower() if isinstance(v, bool) else v
24+
for k, v in params.items()
25+
if v is not None
26+
}
2527

28+
# encode the parameters
29+
return f"{base_path}?{urlencode(filtered_params)}" if filtered_params else base_path

jigsawstack/image_generation.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,33 @@
66
from typing import List, Union
77
from ._config import ClientConfig
88

9+
910
class AdvanceConfig(TypedDict):
1011
negative_prompt: NotRequired[str]
1112
guidance: NotRequired[int]
1213
seed: NotRequired[int]
1314

15+
1416
class ImageGenerationParams(TypedDict):
1517
prompt: Required[str]
1618
"""
1719
The text to generate the image from.
1820
"""
19-
aspect_ratio: NotRequired[Literal["1:1", "16:9", "21:9", "3:2", "2:3", "4:5", "5:4", "3:4", "4:3", "9:16", "9:21"]]
21+
aspect_ratio: NotRequired[
22+
Literal[
23+
"1:1",
24+
"16:9",
25+
"21:9",
26+
"3:2",
27+
"2:3",
28+
"4:5",
29+
"5:4",
30+
"3:4",
31+
"4:3",
32+
"9:16",
33+
"9:21",
34+
]
35+
]
2036
"""
2137
The aspect ratio of the image. The default is 1:1.
2238
"""
@@ -55,6 +71,7 @@ class ImageGenerationParams(TypedDict):
5571

5672
return_type: NotRequired[Literal["url", "binary", "base64"]]
5773

74+
5875
class ImageGenerationResponse(TypedDict):
5976
success: bool
6077
"""
@@ -65,6 +82,7 @@ class ImageGenerationResponse(TypedDict):
6582
The generated image as a blob.
6683
"""
6784

85+
6886
class ImageGeneration(ClientConfig):
6987
config: RequestConfig
7088

@@ -74,23 +92,28 @@ def __init__(
7492
api_url: str,
7593
disable_request_logging: Union[bool, None] = False,
7694
):
77-
super().__init__(api_key, api_url, disable_request_logging=disable_request_logging)
95+
super().__init__(
96+
api_key, api_url, disable_request_logging=disable_request_logging
97+
)
7898
self.config = RequestConfig(
7999
api_url=api_url,
80100
api_key=api_key,
81101
disable_request_logging=disable_request_logging,
82102
)
83103

84-
def image_generation(self, params: ImageGenerationParams) -> ImageGenerationResponse:
104+
def image_generation(
105+
self, params: ImageGenerationParams
106+
) -> ImageGenerationResponse:
85107
path = "/ai/image_generation"
86108
resp = Request(
87109
config=self.config,
88110
path=path,
89-
params=cast(Dict[Any, Any], params), # type: ignore
111+
params=cast(Dict[Any, Any], params), # type: ignore
90112
verb="post",
91113
).perform()
92114
return resp
93-
115+
116+
94117
class AsyncImageGeneration(ClientConfig):
95118
config: RequestConfig
96119

@@ -100,23 +123,23 @@ def __init__(
100123
api_url: str,
101124
disable_request_logging: Union[bool, None] = False,
102125
):
103-
super().__init__(api_key, api_url, disable_request_logging=disable_request_logging)
126+
super().__init__(
127+
api_key, api_url, disable_request_logging=disable_request_logging
128+
)
104129
self.config = RequestConfig(
105130
api_url=api_url,
106131
api_key=api_key,
107132
disable_request_logging=disable_request_logging,
108133
)
109134

110-
async def image_generation(self, params: ImageGenerationParams) -> ImageGenerationResponse:
135+
async def image_generation(
136+
self, params: ImageGenerationParams
137+
) -> ImageGenerationResponse:
111138
path = "/ai/image_generation"
112139
resp = await AsyncRequest(
113140
config=self.config,
114141
path=path,
115-
params=cast(Dict[Any, Any], params), # type: ignore
142+
params=cast(Dict[Any, Any], params), # type: ignore
116143
verb="post",
117144
).perform()
118145
return resp
119-
120-
121-
122-

jigsawstack/prediction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class PredictionResponse(BaseResponse):
3939

4040

4141
class Prediction(ClientConfig):
42-
4342
config: RequestConfig
4443

4544
def __init__(
@@ -67,7 +66,6 @@ def predict(self, params: PredictionParams) -> PredictionResponse:
6766

6867

6968
class AsyncPrediction(ClientConfig):
70-
7169
config: RequestConfig
7270

7371
def __init__(

jigsawstack/request.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def perform(self) -> Union[T, None]:
8181
return cast(T, resp)
8282

8383
def perform_file(self) -> Union[T, None]:
84-
8584
resp = self.make_request(url=f"{self.api_url}{self.path}")
8685

8786
# delete calls do not return a body

jigsawstack/sentiment.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class SentimentResponse(BaseResponse):
4242

4343

4444
class Sentiment(ClientConfig):
45-
4645
config: RequestConfig
4746

4847
def __init__(
@@ -70,7 +69,6 @@ def analyze(self, params: SentimentParams) -> SentimentResponse:
7069

7170

7271
class AsyncSentiment(ClientConfig):
73-
7472
config: RequestConfig
7573

7674
def __init__(

jigsawstack/sql.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class SQLResponse(BaseResponse):
3737

3838

3939
class SQL(ClientConfig):
40-
4140
config: RequestConfig
4241

4342
def __init__(
@@ -65,7 +64,6 @@ def text_to_sql(self, params: SQLParams) -> SQLResponse:
6564

6665

6766
class AsyncSQL(ClientConfig):
68-
6967
config: RequestConfig
7068

7169
def __init__(

0 commit comments

Comments
 (0)