Skip to content

Commit b260fc6

Browse files
committed
fix json name clashes
1 parent 2fc8dcb commit b260fc6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

adafruit_requests.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import errno
4040
import sys
4141

42+
import json as json_module
43+
4244
if sys.implementation.name == "circuitpython":
4345

4446
def cast(_t, value):
@@ -404,9 +406,6 @@ def text(self) -> str:
404406

405407
def json(self) -> Any:
406408
"""The HTTP content, parsed into a json dictionary"""
407-
# pylint: disable=import-outside-toplevel
408-
import json
409-
410409
# The cached JSON will be a list or dictionary.
411410
if self._cached:
412411
if isinstance(self._cached, (list, dict)):
@@ -417,7 +416,7 @@ def json(self) -> Any:
417416

418417
self._validate_not_gzip()
419418

420-
obj = json.load(self._raw)
419+
obj = json_module.load(self._raw)
421420
if not self._cached:
422421
self._cached = obj
423422
self.close()
@@ -588,10 +587,7 @@ def _send_request(
588587
self._send(socket, b"\r\n")
589588
if json is not None:
590589
assert data is None
591-
# pylint: disable=import-outside-toplevel
592-
import json
593-
594-
data = json.dumps(json)
590+
data = json_module.dumps(json)
595591
self._send(socket, b"Content-Type: application/json\r\n")
596592
if data:
597593
if isinstance(data, dict):

0 commit comments

Comments
 (0)