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

Deal with mypy errors w/ type-hinted pynacl 1.5.0 #11714

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11714.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a typechecker problem related to our (ab)use of `nacl.signing.SigningKey`s.
8 changes: 7 additions & 1 deletion tests/crypto/test_event_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import nacl.signing
import signedjson.types
from unpaddedbase64 import decode_base64

from synapse.api.room_versions import RoomVersions
Expand All @@ -35,7 +36,12 @@

class EventSigningTestCase(unittest.TestCase):
def setUp(self):
self.signing_key = nacl.signing.SigningKey(SIGNING_KEY_SEED)
# NB: `signedjson` expects `nacl.signing.SigningKey` instances which have been
# monkeypatched to include new `alg` and `version` attributes. This is captured
# by the `signedjson.types.SigningKey` protocol.
self.signing_key: signedjson.types.SigningKey = nacl.signing.SigningKey(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment above this saying what's happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks. What do you make of 683cccb ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers. Let's get this merged to make everyone's CI happy.

SIGNING_KEY_SEED
)
self.signing_key.alg = KEY_ALG
self.signing_key.version = KEY_VER

Expand Down