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

Commit 796a031

Browse files
author
David Robertson
authored
Bump jsonschema stubs (#12912)
1 parent 6be4953 commit 796a031

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

changelog.d/12912.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump types-jsonschema from 4.4.1 to 4.4.6.

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

synapse/events/validator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import collections.abc
15-
from typing import Iterable, Type, Union
15+
from typing import Iterable, Type, Union, cast
1616

1717
import jsonschema
1818

@@ -103,7 +103,12 @@ def validate_new(self, event: EventBase, config: HomeServerConfig) -> None:
103103
except jsonschema.ValidationError as e:
104104
if e.path:
105105
# example: "users_default": '0' is not of type 'integer'
106-
message = '"' + e.path[-1] + '": ' + e.message # noqa: B306
106+
# cast safety: path entries can be integers, if we fail to validate
107+
# items in an array. However the POWER_LEVELS_SCHEMA doesn't expect
108+
# to see any arrays.
109+
message = (
110+
'"' + cast(str, e.path[-1]) + '": ' + e.message # noqa: B306
111+
)
107112
# jsonschema.ValidationError.message is a valid attribute
108113
else:
109114
# example: '0' is not of type 'integer'

0 commit comments

Comments
 (0)