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

Commit

Permalink
Bump jsonschema stubs (#12912)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson authored May 30, 2022
1 parent 6be4953 commit 796a031
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/12912.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump types-jsonschema from 4.4.1 to 4.4.6.
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 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, Type, Union
from typing import Iterable, Type, Union, cast

import jsonschema

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

0 comments on commit 796a031

Please sign in to comment.