Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit dcdd50e

Browse files
author
David Robertson
authored
Fix mypy errors with latest canonicaljson (#13905)
* Lockfile: update canonicaljson 1.6.0 -> 1.6.3 * Fix mypy errors with latest canonicaljson The change to `_encode_json_bytes` definition wasn't sufficient: ``` synapse/http/server.py:751: error: Incompatible types in assignment (expression has type "Callable[[Arg(object, 'json_object')], bytes]", variable has type "Callable[[Arg(object, 'data')], bytes]") [assignment] ``` Which I think is mypy warning us that the two functions accept different sets of kwargs. Fair enough! * Changelog
1 parent ac1a317 commit dcdd50e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

changelog.d/13905.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix mypy errors with canonicaljson 1.6.3.

poetry.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

synapse/http/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def stopProducing(self) -> None:
705705
self._request = None
706706

707707

708-
def _encode_json_bytes(json_object: Any) -> bytes:
708+
def _encode_json_bytes(json_object: object) -> bytes:
709709
"""
710710
Encode an object into JSON. Returns an iterator of bytes.
711711
"""
@@ -746,7 +746,7 @@ def respond_with_json(
746746
return None
747747

748748
if canonical_json:
749-
encoder = encode_canonical_json
749+
encoder: Callable[[object], bytes] = encode_canonical_json
750750
else:
751751
encoder = _encode_json_bytes
752752

0 commit comments

Comments
 (0)