MatrixSynapse/synapse/events
David Robertson 74e4419eb4
Fix another jsonschema typecheck error (#11830)
Similar to #11817.

In `_create_power_level_validator` we
- retrieve `validator`. This is a class implementing the
  `jsonschema.protocols.Validator` interface. In other words,
  `validator: Type[jsonschema.protocols.Validator]`.
- we then create an second validator class by modifying the original
  `validator`. We return that class, which is also of type
  `Type[jsonschema.protocols.Validator]`.

So the original annotation was incorrect: it claimed we were returning
an instance of jsonSchema.Draft7Validator, not the class (or a subclass)
itself. (Strictly speaking this is incorrect, because `POWER_LEVELS_SCHEMA`
isn't pinned to a particular version of JSON Schema. But there are other
complications with the type stubs if you try to fix this; I felt like
the change herein was a decent compromise that better expresses intent).

(I suspect/hope the typeshed project would welcome an effort to improve
the jsonschema stubs. Let's see if I get some spare time.)
2022-01-25 15:29:28 -05:00
..
__init__.py Add `FrozenEvent.get_state_key` and use it in a couple of places (#11793) 2022-01-21 09:10:01 +00:00
builder.py Get db signatures file to pass mypy (#11312) 2021-11-11 17:04:44 +00:00
presence_router.py Add type hints to synapse.events.*. (#11066) 2021-10-13 07:24:07 -04:00
snapshot.py Add `FrozenEvent.get_state_key` and use it in a couple of places (#11793) 2022-01-21 09:10:01 +00:00
spamcheck.py Add type hints to synapse.events.*. (#11066) 2021-10-13 07:24:07 -04:00
third_party_rules.py Make `check_event_allowed` module API callback not fail open (accept events) when an exception is raised (#11033) 2021-11-01 15:45:56 +00:00
utils.py Do not try to serialize raw aggregations dict. (#11791) 2022-01-21 10:31:31 +00:00
validator.py Fix another jsonschema typecheck error (#11830) 2022-01-25 15:29:28 -05:00