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

Commit

Permalink
Merge branch 'dinsic' into babolivier/username_reg
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Jan 26, 2022
2 parents 26184a9 + 4336c60 commit c7745c5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
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.
1 change: 1 addition & 0 deletions changelog.d/11817.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correct a type annotation in the event validation logic.
1 change: 1 addition & 0 deletions changelog.d/11830.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correct a type annotation in the event validation logic.
1 change: 1 addition & 0 deletions changelog.d/11834.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Workaround a type annotation problem in `prometheus_client` 0.13.0.
4 changes: 2 additions & 2 deletions synapse/events/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import collections.abc
from typing import Iterable, Union
from typing import Iterable, Type, Union

import jsonschema

Expand Down Expand Up @@ -246,7 +246,7 @@ def _ensure_state_event(self, event: Union[EventBase, EventBuilder]) -> None:

# This could return something newer than Draft 7, but that's the current "latest"
# validator.
def _create_power_level_validator() -> jsonschema.Draft7Validator:
def _create_power_level_validator() -> Type[jsonschema.Draft7Validator]:
validator = jsonschema.validators.validator_for(POWER_LEVELS_SCHEMA)

# by default jsonschema does not consider a frozendict to be an object so
Expand Down
3 changes: 2 additions & 1 deletion synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"msgpack>=0.5.2",
"phonenumbers>=8.2.0",
# we use GaugeHistogramMetric, which was added in prom-client 0.4.0.
"prometheus_client>=0.4.0",
# 0.13.0 has an incorrect type annotation, see #11832.
"prometheus_client>=0.4.0,<0.13.0",
# we use `order`, which arrived in attrs 19.2.0.
# Note: 21.1.0 broke `/sync`, see #9936
"attrs>=19.2.0,!=21.1.0",
Expand Down
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(
SIGNING_KEY_SEED
)
self.signing_key.alg = KEY_ALG
self.signing_key.version = KEY_VER

Expand Down

0 comments on commit c7745c5

Please sign in to comment.