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

Fix another jsonschema typecheck error #11830

Merged
merged 3 commits into from
Jan 25, 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
2 changes: 1 addition & 1 deletion changelog.d/11817.misc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Compatibility with updated type hints for jsonschema 4.4.0.
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.
clokep marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 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,9 +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.
#
# See https://github.com/python/typeshed/issues/7028 for the ignored return type.
def _create_power_level_validator() -> jsonschema.Draft7Validator: # type: ignore[valid-type]
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