Skip to content

Commit

Permalink
unnecessary utf decode pre-loads
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoberheide committed Nov 14, 2024
1 parent 2cf8f1d commit e4739d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pylutron_caseta/leap.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def run(self):
if received == b"":
break

resp_json = orjson.loads(received.decode("UTF-8"))
resp_json = orjson.loads(received)

if isinstance(resp_json, dict):
tag = resp_json.get("Header", {}).pop("ClientTag", None)
Expand Down
2 changes: 1 addition & 1 deletion src/pylutron_caseta/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def async_read_json(self, timeout):
return None

LOGGER.debug("received: %s", buffer)
return orjson.loads(buffer.decode("UTF-8"))
return orjson.loads(buffer)

async def async_write_json(self, obj):
"""Write an object."""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_leap.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def test_call(pipe: Pipe):
"""Test basic call and response."""
task = asyncio.create_task(pipe.leap.request("ReadRequest", "/test"))

received = orjson.loads((await pipe.test_reader.readline()).decode("utf-8"))
received = orjson.loads(await pipe.test_reader.readline())

# message should contain ClientTag
tag = received.get("Header", {}).pop("ClientTag", None)
Expand Down Expand Up @@ -232,7 +232,7 @@ def handler(response):

task = asyncio.create_task(pipe.leap.subscribe("/test", handler))

received = orjson.loads((await pipe.test_reader.readline()).decode("utf-8"))
received = orjson.loads(await pipe.test_reader.readline())

# message should contain ClientTag
tag = received.get("Header", {}).pop("ClientTag", None)
Expand Down Expand Up @@ -287,7 +287,7 @@ def _handler(_: Response):

task = asyncio.create_task(pipe.leap.subscribe("/test", _handler))

received = orjson.loads((await pipe.test_reader.readline()).decode("utf-8"))
received = orjson.loads(await pipe.test_reader.readline())

tag = received.get("Header", {}).pop("ClientTag", None)
response_obj = {
Expand Down

0 comments on commit e4739d8

Please sign in to comment.