Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI by fixing the type errors for PyNaCl #484

Merged
merged 8 commits into from Jan 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/484.misc
@@ -0,0 +1 @@
Fix type errors caused by an update to PyNaCl.
1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -61,7 +61,6 @@ mypy_path = "stubs"
[[tool.mypy.overrides]]
module = [
"idna",
"nacl.*",
"netaddr",
"prometheus_client",
"sentry_sdk",
Expand Down
11 changes: 9 additions & 2 deletions sydent/config/crypto.py
Expand Up @@ -14,8 +14,10 @@

from configparser import ConfigParser

import nacl
import nacl.encoding
import nacl.signing
import signedjson.key
import signedjson.types

from sydent.config._base import BaseConfig

Expand All @@ -32,6 +34,11 @@ def parse_config(self, cfg: "ConfigParser") -> bool:

save_key = False

# N.B. `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

if signing_key_str == "":
print(
"INFO: This server does not yet have an ed25519 signing key. "
Expand All @@ -46,7 +53,7 @@ def parse_config(self, cfg: "ConfigParser") -> bool:
print("INFO: Updating signing key format: brace yourselves")

self.signing_key = nacl.signing.SigningKey(
signing_key_str, encoder=nacl.encoding.HexEncoder
signing_key_str.encode("ascii"), encoder=nacl.encoding.HexEncoder
)
self.signing_key.version = "0"
self.signing_key.alg = signedjson.key.NACL_ED25519
Expand Down