Skip to content

Commit 5ebe84d

Browse files
Update validate.nsfw to either accept params or blob, but not both.
1 parent 8f7e539 commit 5ebe84d

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

jigsawstack/validate.py

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,24 @@ def email(self, params: EmailValidationParams) -> EmailValidationResponse:
102102
).perform_with_content()
103103
return resp
104104

105-
@overload
106-
def nsfw(self, params: NSFWParams) -> NSFWResponse: ...
107-
@overload
108-
def speech_to_text(self, file: bytes, options: Optional[NSFWParams] = None) -> NSFWParams: ...
109-
110-
def nsfw(
111-
self,
112-
blob: Union[NSFWParams, bytes],
113-
options: Optional[NSFWParams] = None,
114-
) -> NSFWResponse:
115-
if isinstance(blob, dict):
105+
def nsfw(self, params: Union[NSFWParams, bytes]) -> NSFWResponse:
106+
path="/validate/nsfw"
107+
if isinstance(params, dict):
116108
resp = Request(
117109
config=self.config,
118-
path="/validate/nsfw",
119-
params=cast(Dict[Any, Any], blob),
110+
path=path,
111+
params=cast(Dict[Any, Any], params),
120112
verb="post",
121113
).perform_with_content()
122114
return resp
123115

124-
options = options or {}
125-
path = build_path(base_path="/validate/nsfw", params=options)
126-
content_type = options.get("content_type", "application/octet-stream")
127-
headers = {"Content-Type": content_type}
128-
116+
_headers = {"Content-Type": "application/octet-stream"}
129117
resp = Request(
130118
config=self.config,
131119
path=path,
132-
params=options,
133-
data=blob,
134-
headers=headers,
120+
params={}, #since we're already passing data.
121+
data=params,
122+
headers=_headers,
135123
verb="post",
136124
).perform_with_content()
137125
return resp
@@ -204,37 +192,25 @@ async def email(self, params: EmailValidationParams) -> EmailValidationResponse:
204192
verb="get",
205193
).perform_with_content()
206194
return resp
207-
208-
@overload
209-
async def nsfw(self, params: NSFWParams) -> NSFWResponse: ...
210-
@overload
211-
async def speech_to_text(self, file: bytes, options: Optional[NSFWParams] = None) -> NSFWParams: ...
212-
213-
async def nsfw(
214-
self,
215-
blob: Union[NSFWParams, bytes],
216-
options: Optional[NSFWParams] = None,
217-
) -> NSFWResponse:
218-
if isinstance(blob, dict):
195+
196+
async def nsfw(self, params: Union[NSFWParams, bytes]) -> NSFWResponse:
197+
path="/validate/nsfw"
198+
if isinstance(params, dict):
219199
resp = await AsyncRequest(
220200
config=self.config,
221-
path="/validate/nsfw",
222-
params=cast(Dict[Any, Any], blob),
201+
path=path,
202+
params=cast(Dict[Any, Any], params),
223203
verb="post",
224204
).perform_with_content()
225205
return resp
226206

227-
options = options or {}
228-
path = build_path(base_path="/validate/nsfw", params=options)
229-
content_type = options.get("content_type", "application/octet-stream")
230-
headers = {"Content-Type": content_type}
231-
207+
_headers = {"Content-Type": "application/octet-stream"}
232208
resp = await AsyncRequest(
233209
config=self.config,
234210
path=path,
235-
params=options,
236-
data=blob,
237-
headers=headers,
211+
params={},
212+
data=params,
213+
headers=_headers,
238214
verb="post",
239215
).perform_with_content()
240216
return resp

0 commit comments

Comments
 (0)