Skip to content

Commit 8f5108e

Browse files
refactor: remove requests json hack for requests<2.4.2
1 parent e092506 commit 8f5108e

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

deepl/http_client.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from typing import Dict, Optional, Tuple, Union
1515
from .util import log_info
1616
from deepl import util
17-
import json as json_module
1817

1918

2019
user_agent = None
@@ -229,16 +228,8 @@ def _prepare_request(
229228
self._app_info_version,
230229
),
231230
)
232-
# TODO review when minimum Python version is raised
233-
if tuple(map(int, requests.__version__.split("."))) >= (2, 4, 2):
234-
kwargs["json"] = json
235-
elif json is not None:
236-
# This is fine, see official docs
237-
# https://requests.readthedocs.io/en/latest/user/quickstart/#more-complicated-post-requests # noqa: E501
238-
data = json_module.dumps(json) # type: ignore[assignment]
239-
headers["Content-Type"] = "application/json"
240231
return requests.Request(
241-
method, url, data=data, headers=headers, **kwargs
232+
method, url, data=data, headers=headers, json=json, **kwargs
242233
).prepare()
243234
except Exception as e:
244235
raise DeepLException(

0 commit comments

Comments
 (0)